How to use owner-drawn controls in Visual C# .NET or in Visual C# 2005 by using ODForm

Article translations Article translations
Article ID: 326143 - View products that this article applies to.
This article was previously published under Q326143
Expand all | Collapse all

On This Page

SUMMARY

The ODForm sample demonstrates how to use owner-drawn controls in Visual C# .NET or in Visual C# 2005. The .NET Framework provides support for features such as owner-drawn customization and HTML Help. This sample demonstrates how to take advantage of these features in Visual C# .NET or in Visual C# 2005.

MORE INFORMATION

The ODForm sample mimics a number of Owner-Draw SDK samples from the MSDN documentation. This article intends to show you that the Owner-Draw functionality that you can achieve in unmanaged code is also possible in managed code. Additionally, this article provides some simple examples of context help and an implementation of a dockable toolbar.

The best use of this sample would probably be to load the project in the Visual Studio .NET or Visual Studio 2005 IDE and examine the property settings and event overrides for the different elements. For example, the combo box has the DrawMode property set to OwnerDrawFixed, and the DrawItem event is handled to add a custom image for each item. Some other details are managed by checking the DrawItemState, so that a dark background color can be used to indicate that an item is currently selected. All other user interface elements in the sample have been treated in a similar manner.

For context-sensitive help, the .NET Framework HelpProvider object stores the path to the Help file, and the individual elements expose HelpKeyword and HelpNavigator properties, allowing for a range of choices when displaying help information. The list box takes advantage of the HelpString property to simply display a pop-up window of information that can be drawn from the Help file or, as in this case, simply typed into the property window.

The dockable toolbar implementation demonstrates how easy it is to implement this functionality using Visual C# .NET or Visual C# 2005. The sample reparents the toolbar to a docking form when a drag attempt is detected, and places the toolbar back on the main form when the docking window is dragged near the original toolbar location.

Download Information

The following file is available for download from the Microsoft Download Center:
Collapse this imageExpand this image
Download
Download the ODForm.exe package now. For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

REFERENCES

For more information, visit the following Microsoft Web site:
.NET Samples - How To: Windows Forms
http://msdn.microsoft.com/en-us/library/aa308973.aspx

Properties

Article ID: 326143 - Last Review: December 11, 2006 - Revision: 3.4
APPLIES TO
  • Microsoft Visual C# 2005 Express Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
Keywords: 
kbdownload kbtoolbar kbctrl kbsample kbhowto kbfile kbwindowsforms KB326143

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com