How can I make a comboxbox list the first item in the collaction by default
in other words i have a collection list
1
2
3
4
5
When program loads I want combobox to load 1
Thanks
Printable View
How can I make a comboxbox list the first item in the collaction by default
in other words i have a collection list
1
2
3
4
5
When program loads I want combobox to load 1
Thanks
did you tried:
Code:ComboBox1.SelectedIndex = 0
Tip: you can set the combobox DropDownStyle property to DropDownList
this will remove the empty value from your combobox.
use following code
basically, Combobox.selectedIndex will accept/returns an integer value of item in ListCode:Combobox.selectedIndex = 1
do you set the selectedindex to 0 after you populating the cb?
hey billboy,
u have 5 items in your cmbbox, isn't it ???:confused:
so u have bydefault 1 as selected always..right ???:confused:
if u want the same then just fill the list and then after populating it...set selectedIndex = 1
I must be blind i dont see a property setting for selected index, do I have to code it ??
Code:Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("1")
ComboBox1.Items.Add("2")
ComboBox1.Items.Add("3")
ComboBox1.Items.Add("4")
ComboBox1.SelectedIndex = 0
End Sub
you have to do code for it like this...
just do the code on your form load event
Code://fill combo box code here
Combobox1.selectedIndex = 1