System.Windows.Forms.ToolStripComboBox Class

Represents a System.Windows.Forms.ToolStripComboBox that is properly rendered in a System.Windows.Forms.ToolStrip.

See Also: ToolStripComboBox Members

Syntax

[System.Windows.Forms.Design.ToolStripItemDesignerAvailability(System.Windows.Forms.Design.ToolStripItemDesignerAvailability.ToolStrip | System.Windows.Forms.Design.ToolStripItemDesignerAvailability.MenuStrip | System.Windows.Forms.Design.ToolStripItemDesignerAvailability.ContextMenuStrip)]
[System.ComponentModel.DefaultProperty("Items")]
public class ToolStripComboBox : ToolStripControlHost

Remarks

System.Windows.Forms.ToolStripComboBox is the System.Windows.Forms.ComboBox optimized for hosting in a System.Windows.Forms.ToolStrip. A subset of the hosted control's properties and events are exposed at the System.Windows.Forms.ToolStripComboBox level, but the underlying System.Windows.Forms.ComboBox control is fully accessible through the ToolStripComboBox.ComboBox property.

A System.Windows.Forms.ToolStripComboBox displays an editing field combined with a System.Windows.Forms.ListBox, allowing the user to select from the list or to enter new text. By default, a System.Windows.Forms.ToolStripComboBox displays an edit field with a hidden drop-down list. The ToolStripComboBox.DropDownStyle property determines the style of combo box to display. You can enter a value that allows for a simple drop-down, where the list always displays, a drop-down list box, where the text portion is not editable and you must select an arrow to view the drop-down list box, or the default drop-down list box, where the text portion is editable and the user must press the arrow key to view the list. To always display a list that the user cannot edit, use a System.Windows.Forms.ListBox control.

To add objects to the list at run time, assign an array of object references with the ToolStripItemCollection.AddRange(ToolStripItem[]) method. The list then displays the default string value for each object. You can add individual objects with the erload:System.Windows.Forms.ToolStripItemCollection.Add method.

In addition to display and selection functionality, the System.Windows.Forms.ToolStripComboBox also provides features that enable you to efficiently add items to the System.Windows.Forms.ToolStripComboBox and to find text within the items of the list. The ToolStripComboBox.BeginUpdate and ToolStripComboBox.EndUpdate methods enable you to add a large number of items to the System.Windows.Forms.ToolStripComboBox without the control being repainted each time an item is added to the list. The ToolStripComboBox.FindString(string) and ToolStripComboBox.FindStringExact(string) methods enable you to search for an item in the list that contains a specific search string.

Use the ToolStripComboBox.SelectedIndex property to get or set the current item in the drop-down list, and use the ToolStripComboBox.SelectedItem property to get or set a reference to the current item in the drop-down list.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0