1 / 22

Tips and Tricks: Answers to Common Questions when Building Windows Forms Applications

Tips and Tricks: Answers to Common Questions when Building Windows Forms Applications. Mike Harsh PRSL001 Program Manager Microsoft Corporation. Agenda. 5 real world customer questions and solutions TabControl with tabs on bottom Docking confusion Read-only ComboBox

urvi
Télécharger la présentation

Tips and Tricks: Answers to Common Questions when Building Windows Forms Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tips and Tricks: Answers to Common Questions when Building Windows Forms Applications Mike Harsh PRSL001 Program Manager Microsoft Corporation

  2. Agenda • 5 real world customer questions and solutions • TabControl with tabs on bottom • Docking confusion • Read-only ComboBox • Tracking the true visibility of a control in a container • DataBinding DateTimePicker to null • Questions

  3. Non-Top Aligned TabsVisual styles and TabControl Alignment

  4. Non-Top Aligned TabsThe problem ComCtl v6 doesn’t implement other alignments Visual styles disabled Visual styles enabled

  5. Non-Top Aligned TabsThe Solution • Draw the TabControl UI in code • Set ControlStyles.UserDraw to true

  6. Docking Confusion What order are controls docked in?

  7. Docking ConfusionThe problem • Controls are docked based on their order in the Controls collection • This is known as Z-order • Docking issues due to Z-order can be tough to debug by looking at the designer

  8. Docking ConfusionThe Solution • Use the new Document Outline window in Visual Studio • Ctrl+alt+t in the standard profile

  9. ReadOnly ComboBox

  10. ReadOnly ComboBoxThe problem ComboBox doesn’t support the concept of readonly Workaround of disabling the control doesn’t allow selection of text

  11. ReadOnly ComboBoxThe Solution • Implement a ReadOnly property on a ComboBox subclass • Create a text field and a disabled button to place over the ComboBox

  12. Tracking The True Visibility Of A Control In A Container

  13. True Control Visibility The problem Visible property always returns the correct state. VisibleChanged is only raised when the Visible property of the control is modified It’s not raised when a control’s parent’s Visible property is set to false

  14. True Control VisibilityThe Solution • Create a component that listens for all visibility changes and notifies a control when it is no longer on the screen • Uses a window hook on the thread and listen for the WM_SHOWWINDOW and WM_WINDOWPOSCHANGING messages • Users register a handler for a control visibility change

  15. DataBinding DateTimePicker Null support for DateTimePicker

  16. DataBinding DateTimePicker The problem • DateTimePicker has no UI for displayingNULL • DateTimePicker’s Value property is aDateTime • You cannot set NULL to a value type • Early bound compile error • Late bound exception • DataBinding infrastructure catches the exception, but doesn’t set the value

  17. DataBinding DateTimePicker The Solution • Create a control that extends DateTimePicker and adds a Nullable<DateTime> property • Use the DateTimePicker’s check box as the null UI • Bind to the new property instead

  18. Summary • 5 real world customer questions and solutions • TabControl with tabs on bottom • Docking confusion • Read-only ComboBox • Tracking the true visibility of a control in a container • DataBinding DateTimePicker to null

  19. Community Resources • At PDC • Interesting in helping with Visual Studio and Developer Platform’s future planning?  Sign up at the Tools and Language Track Lounge to attend a focus group. • For more information, go see • PRS321  Windows Forms: Integrating Windows Forms and Windows Presentation Foundation ("Avalon") (Thur 11:30am) • FUN222  Windows Vista: What’s New in Software Installation for Windows Vista: Exploring the Windows Installer (MSI) and ClickOnce Options (Fri 1pm) • Labs • FUNHOL15 ClickOnce Deployment • PRSHOL17 New UI Features in Windows Forms • PRSHOL18 New Data Features in Windows Forms • PRSHOL19 Windows Forms: Advanced Layout • The Windows Forms table in the Presentation track lounge • Ask The Experts • After PDC • MSDN dev center: http://msdn.microsoft.com/windowsforms/ • MSDN Forums: http://forums.microsoft.com/msdn/default.aspx?ForumGroupID=2

  20. © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

  21. Richtextbox With A Visual Style Border

  22. Flashing A Window In The Taskbar

More Related