DQDQbBJBiTPb2cT{qTyT=2c{y=c=yPTTcBaEBBCDAr-L-~~| 56564WYWXWWWW

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.`330px`330px`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 33; 33.Windows.Forms3namespace WindowsFormsApplication1 { 23partial 3Form1 : Form 2{ 223Form1() 22{ 222InitializeComponent(); 22} 223_selected3; 223 _text3223 34comboBox1_Selected3Changed4(object sender, EventArgs e) 22{4 2223Called when a 3index is selected. 2224_selected33comboBox1.Selected3; 2223(); 22} 223 34comboBox1_TextChanged4(object sender, EventArgs e) 22{4 2223Called whenever text changes. 2224_text3comboBox1.Text; 2223(); 22} 2233() 22{ 222this.Text33.Format(4"Text: {0}; Selected3: {1}"4, 2222_text, 2222_selected3); 22} 2} }4

!Ddemonstrates ComboBox event handlers