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
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
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
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.
The following file is available for download from the Microsoft Download Center:
Download the ODForm.exe package now.
Collapse this imageExpand this image
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
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
Samples - How To: Windows Forms