Selected in ListBox not actually selecting?

wjyoung

Registered User.
Local time
Yesterday, 23:55
Joined
Jan 21, 2011
Messages
13
I have cascading listboxes, where the content of one depends upon the value selected in the previous.

I want to preselect the first item in the list box by default, so I use this:
me.ListBox.Selected(1) = True
The problem is when I check the value of the selected item, I get myValue = null as below:
myValue = me.ListBox.Value
I know I could use me.ListBox.ItemData(1), but for my own future reference I was hoping to confirm whether Selected = True has only a visual effect.
 
Thanks, jdraw.

In summary:

Don't select an item in a list box using .Selected = True like this:
me.ListBox.Selected(index) = True
myValue = me.ListBox.Value
Do select an item in a list box by setting the value of the list box itself equal to the value of a particular list box item like this:
me.ListBox = me.ListBox.ItemData(index)
myValue = me.ListBox.Value
This seems to have solved my problem. Thank you very much.
 

Users who are viewing this thread

Back
Top Bottom