Export (0) Print
Expand All

ComboBoxCtl Sample: Demonstrates the Windows Forms ComboBox Control

Visual Studio .NET 2003

The ComboBoxCtl sample shows how to use Windows Forms in a .NET Framework application, focusing on the functionality of combo boxes:

  • Display type: simple, drop-down, and drop-down list
  • Drawing mode
  • Item height when the combo box is drawn as "owner draw fixed"
  • Other properties, such as how many items should be displayed when the list is shown and whether the items should be sorted

Building and Running the Sample

To build and run ComboBoxCtl using Visual Studio

  1. In the Visual Studio IDE, open the solution file comboboxctl.sln.
  2. In Solution Explorer, right-click the ComboBoxCtl solution.
  3. On the shortcut menu, click Build.
  4. On the Debug menu, click Start.

The application displays two combo boxes filled with colors that control the colors in the box in the lower right corner. The aspects of these combo boxes are determined by the collection of check boxes and combo boxes found on the right. For example, by selecting the Style to "dropdown list" and the Draw mode to "owner draw fixed," the combo boxes on the left display the name of the color using the corresponding color along with a rectangle filled with the same. The implementation code for this is in ComboBoxCtl::combo_DrawItem, which is invoked for every item when the drawing mode is owner draw.

Classes and Keywords

This sample demonstrates the following classes:

ComboBox; Panel; CheckBox; ToolTip; GroupBox; Form

This sample demonstrates the following keywords:

ComboBox::Size; ComboBox::DropDownStyle; ComboBox::DrawMode; ComboBox::TabIndex; ComboBox::Sorted; ComboBox::Text; ComboBox::Location; ComboBox::add_KeyPress; ComboBox::add_DrawItem; ComboBox::add_MeasureItem

See Also

Managed Extensions for C++ Samples

Show:
© 2014 Microsoft