G
Guest
Ok, I have a DataTable:
ID Name
-- ------------
1 John
2 Jacob
3 Jingleheimer
4 Schmidt
5 John
I have set my DisplayMember of my listbox to "Name"; my valueMember to "ID"
and my datasource to myDataTable. So far so good. It shows the list, and
all is well.
What I need to do is be able to set the Selected Item via code. I have done
everything I can think of here, and nothing seems to work. I have tried:
myListBox.SelectedValue = 5 (this is the obvious one that should have worked)
myListBox.SelectedItem = mySelectedRow (a valid reference to the selected
rowview)
myListbox.SetSelected("John", True) This sets the first John, not the
second one.
myListbox.FindString ("John") same problem as above.
I've done this before... What simple thing am I missing here???
ID Name
-- ------------
1 John
2 Jacob
3 Jingleheimer
4 Schmidt
5 John
I have set my DisplayMember of my listbox to "Name"; my valueMember to "ID"
and my datasource to myDataTable. So far so good. It shows the list, and
all is well.
What I need to do is be able to set the Selected Item via code. I have done
everything I can think of here, and nothing seems to work. I have tried:
myListBox.SelectedValue = 5 (this is the obvious one that should have worked)
myListBox.SelectedItem = mySelectedRow (a valid reference to the selected
rowview)
myListbox.SetSelected("John", True) This sets the first John, not the
second one.
myListbox.FindString ("John") same problem as above.
I've done this before... What simple thing am I missing here???