|
-
Nov 3rd, 2005, 02:07 AM
#1
Thread Starter
Frenzied Member
combobox first item show when populated
Hi ,
I have this combobox that is being populated form a table. This Ive done , now I need it to have a specific item show as default. Since the combobox needs to be indexed, how can I code it to show always this specific item.
I tried to have
MyCombobox.GetItemText = "MyItemText"
but does not work. Any help please. Thanks
-
Nov 3rd, 2005, 02:14 AM
#2
Re: combobox first item show when populated
Try this... the items are objects.. if they are strings, just cast them..
VB Code:
Dim mytest As String
mytest = DirectCast(ComboBox1.Items.Item(0), String) '0 is first item...
-
Nov 3rd, 2005, 02:20 AM
#3
Re: combobox first item show when populated
K.. if you just want to select the item... then just call the selectedindex..
VB Code:
ComboBox1.SelectedIndex = 0 'selects the first item in the collection
-
Nov 3rd, 2005, 02:51 AM
#4
Re: combobox first item show when populated
How have you populated this ComboBox? The most likely ways to select your default value would be to set the SelectedIndex, SelectedItem or SelectedValue property. Which one you use would depend on how you've populated the list and how you can identify the default value.
-
Nov 4th, 2005, 03:52 AM
#5
Thread Starter
Frenzied Member
Re: combobox first item show when populated
hi,
Still not loading first item. What I am doing is to populate the combobox from database which loads data except that the first item is not showing up. It is getting them sorted so obviously the first one that was entered is not showing up.
I dont know why cos the field is not indexed and the combobox properties's sorted is set to false. Any ideas why.
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
|