ComboBox` is a combination TextBox with a drop-down. Its drop-down list presents preset choices. The user can type anything into the ComboBox. Alternatively, he or she can select something from the list.`330`To begin,` please create a new Windows Forms application and add a ComboBox to it. You can then right-click on the ComboBox and add the SelectedIndexChanged and TextChanged event handlers in the Properties dialog. `Program: `When you change the text by typing in the ComboBox or by clicking on the list of Items, the event handlers are triggered.`Items: `Please see the section on the Items property before running the program. With Items we add strings to the ComboBox.`Text.` The Text property of the ComboBox functions much like the Text property of a TextBox. If you assign to the Text property, the current value in the ComboBox will change. You can also read the Text property and assign string variables to it. `To clear it, you can assign it to an empty string literal. This is an effective way to clear many properties.`Empty String `empty-string`String Literal `string-literal`Items.` The Items property contains the strings that are found in the drop-down part of the ComboBox. You can type the Items line-by-line into Visual Studio through the Items dialog, or you can dynamically add them during runtime. `To add Items, call the Add method: use the syntax comboBox1.Add("Value"). You can also Clear the ComboBox with Clear().`Dialog usage.` Conceptually, the ComboBox is used to represent a text input with a set of associated, predefined values that are easy to select. For this reason, it is a good choice for preference dialogs.`You can use` ComboBox controls and have preset values that are present in the drop-downs, but allow your users to select any value by typing it in directly. This avoids the need for more than one control.`AutoComplete.` There are three properties for AutoComplete on the ComboBox: the AutoCompleteCustomSource, the AutoCompleteMode, and the AutoCompleteSource. The AutoCompleteMode property can be set to suggest, append or both. `Source properties let you specify the set of strings that are used as suggestions.`DropDown styles.` There are three DropDown style properties. They are DropDownHeight, DropDownStyle and DropDownWidth. The DropDownHeight and DropDownWidth properties seem not to affect the visual appearance. Windows uses its default widgets. `You can remove the drop-down entirely (with Simple), or make it so the text is not editable (with DropDownList).`MaxDropDownItems.` This property sets the max items visible in the drop-down. It has no effect when IntegralHeight is set to true. But if IntegralHeight is false, it limits the count of items visible (a scroll bar may appear). `Thanks to Clarence Ravel for showing that MaxDropDownItems has an effect for a false IntegralHeight.`Summary.` The ComboBox control combines the TextBox and a drop-down list. It represents a useful hybrid widget in Windows Forms. It is ideal for dialogs where some suggestions for an input may be known, but any value must be accepted. `Review: `The ComboBox can streamline your interface by merging user interface controls.

234 3P3O; 3P3O.Windows.Forms3Snamespace WindowsFormsApplication1 { 23=partial 3DForm1 : Form 2{ 223=Form1() 22{3'InitializeComponent(); 22} 223s_selected3\; 223L _text3S223: 3f4comboBox1_Selected3\Changed4(object sender, EventArgs e) 22{43'3{Called when a 3windex is selected.3'4_selected3\3zcomboBox1.Selected3\;3'35(); 22} 223: 3f4comboBox1_TextChanged4(object sender, EventArgs e) 22{43'3{Called whenever text changes.3'4_text3zcomboBox1.Text;3'35(); 22} 223f35() 22{3'this.Text3z3L.Format(4"Text: {0}; Selected3\: {1}"4,3'2_text,3'2_selected3\); 22} 2} }4

Ddemonstrates ComboBox event handlers