|
-
Jul 22nd, 2004, 09:47 AM
#1
Thread Starter
Member
changing the default shown value in a drop down list from code in .net
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
-
Jul 22nd, 2004, 09:50 AM
#2
Frenzied Member
VB Code:
comboBox1.SelectedIndex = index
that's assuming there's data in the collection. Otherwise, that will give an error. Is that your case?
-
Jul 22nd, 2004, 09:55 AM
#3
Thread Starter
Member
i'm not dynamically populating it. It has a constant collection of items.
-
Jul 22nd, 2004, 10:12 AM
#4
Frenzied Member
then that should work perfectly for you. 
you can also do it like this :
VB Code:
ComboBox1.SelectedItem = ComboBox1.Items.Item(index)
the latter is just more to type.
-
Jul 22nd, 2004, 12:03 PM
#5
New Member
does that still work if the data in the combo box is from a data source?
-
Jul 22nd, 2004, 12:08 PM
#6
Frenzied Member
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.
-
Jul 22nd, 2004, 12:45 PM
#7
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|