How to unselect a combobox ???

C

Chris Zopers

Hello,

I can't seem to unselect comboboxes in VB.NET.
I've set the datasource, valuemember and displaymember properties of the
combobox. The first item from the datasource is always selected in the
combobox, even when I set the SelectedIndex property to -1.

I've read the common used solution that setting the SelectedIndex
property twice to -1 should work:

ComboBox.SelectedIndex = -1
ComboBox.SelectedIndex = -1

But that solution doesn't seem to work either!!!

In the load event, nothing helps to unselect comboboxes. When I use
SelectedIndex = -1 in a button-event, it works just fine, but all
comboboxes should be unselected right after loading the form.

Does anyone have a good solution for this problem?

Greetings,
Chris.
 
C

Chris Zopers

Hi there,

I just tried ComboBox.SelectedIndex = Nothing, but the first item from
the datasource is still selected.

I can't find the combobox member 'ClearSelected'! I'm using Visual
Studio 2002, maybe 'ClearSelected' is only available in higher versions?

Greetings,
Chris
 
H

Herfried K. Wagner [MVP]

Chris Zopers said:
I just tried ComboBox.SelectedIndex = Nothing, but the first item from
the datasource is still selected.

Set 'SelectedIndex' to -1 twice.
 

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