Hey,
How would I go about changing the default shown value in a drop down list from code in vb.net. I want to pass it parameters and change what is shown by default depending on what they are.
Thanx ~Cran56 :confused:
Hey,
How would I go about changing the default shown value in a drop down list from code in vb.net. I want to pass it parameters and change what is shown by default depending on what they are.
Thanx ~Cran56 :confused:
VB Code:
comboBox1.SelectedIndex = index
that's assuming there's data in the collection. Otherwise, that will give an error. Is that your case?
i'm not dynamically populating it. It has a constant collection of items.
then that should work perfectly for you. :D
you can also do it like this :
VB Code:
ComboBox1.SelectedItem = ComboBox1.Items.Item(index)
the latter is just more to type.
does that still work if the data in the combo box is from a data source?
yep. as long as you know the index of the value you're after. Just be sure to call upon the index AFTER the box is populated otherwise, an error is generated.
thanks I will try that