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

This article was previously published under Q326143
This article has been archived. It is offered "as is" and will no longer be updated.
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.
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:
DownloadDownload 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.
For more information, visit the following Microsoft Web site:
.NET Samples - How To: Windows Forms

Article ID: 326143 - Last Review: 01/17/2015 05:49:53 - Revision: 3.4

Microsoft Visual C# 2005 Express Edition, Microsoft Visual C# .NET 2002 Standard Edition

  • kbnosurvey kbarchive kbdownload kbtoolbar kbctrl kbsample kbhowto kbfile kbwindowsforms KB326143
ERROR: at System.Diagnostics.Process.Kill() at Microsoft.Support.SEOInfrastructureService.PhantomJS.PhantomJSRunner.WaitForExit(Process process, Int32 waitTime, StringBuilder dataBuilder, Boolean isTotalProcessTimeout)