ListBox.SelectedItem = "whatever" fails with data-bound?

G

Grok

Is this a feature of ListBox that when using a DataSource, the
SelectedItem acts different?

Added ListBox1 and ListBox2 to a form.
ListBox1 is bound to a DataSource where DisplayedMember=name and
ValueMember=id from the table.
ListBox2 filled by AddRange(New String() {"One", "Two", "Three",
"Four", "Five"})

ListBox2.SelectedItem = "Three"
selected the item "Three" in the Items.

but ListBox1.SelectedItem = "(name of any item in the list)"
does not cause any item to be selected.

How does one use .SelectedItem = "value" with data-bound list
controls?
 
C

Cor Ligthert[MVP]

Grok,

That depends on your datasource, however it has at least to implement in
whatever way the Ilist's

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top