combo box
DESCRIPTION
visual basic 2010 combobox toolTRANSCRIPT
![Page 2: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/2.jpg)
ComboBox
A ComboBox control is a combination of a TextBox and a ListBox control
![Page 3: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/3.jpg)
Open new project
![Page 4: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/4.jpg)
Add ComboBox \ Item property \ press ... Button \ type White, Red, Black & Yellow
Add items from Design window
![Page 5: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/5.jpg)
Run Time
![Page 6: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/6.jpg)
You can add same items at run-time
Another method for adding items
Add items by Code
![Page 7: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/7.jpg)
Add 1 Button and Fix it
![Page 8: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/8.jpg)
Run Time
![Page 9: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/9.jpg)
Sb could be anything else like X, Y or Z
![Page 10: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/10.jpg)
Add another Button and Fix it
![Page 11: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/11.jpg)
Run Time
![Page 12: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/12.jpg)
Double click on Button2 and type yellow phrase
![Page 13: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/13.jpg)
Add GroupBox, Button and TextBox
![Page 14: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/14.jpg)
Run Time
TextBox Will have the same value as ComboBox
![Page 15: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/15.jpg)
![Page 16: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/16.jpg)
Error
If there is no selected item ComboBox1.SelectedIndex will be
-1 and this will produce an Error
ComboBox1.Items
White
Red
Black
yellow
ComboBox1.SelectedIndex
0
1
2
3
Dim X As String =ComboBox1.Items(ComboBox1.SelectedIndex) TextBox1.Text = X
![Page 17: Combo box](https://reader033.vdocuments.site/reader033/viewer/2022061211/5491c340ac795934288b4605/html5/thumbnails/17.jpg)