combobox.SelectedIndex = -1 does not empty combobox

G

Guest

Hi:
I have 3 combobox in my winform, Entity, company and department, one drive
another.
I like have Entity bind to a datasource and have a default value selected,
so company also get a datasource from entity. but not default value. I would
like user to pick from the list.
I also have a Reset button which reset these 3 combobox back to previous
status when get messed.
Now the Reset button work just fine. but the initialize status always
wrong with default value in company combobox.
here is the code:
cboCompanies.DataSource = dt;
cboCompanies.DisplayMember = "COMPANY_NAME";
cboCompanies.ValueMember = "COMPANY_ID";
// follow the instructor of microsoft bug report
// http://support.microsoft.com/default.aspx?scid=kb;en-us;327244
cboCompanies.SelectedIndex = -1;
cboCompanies.SelectedIndex = -1;

Have any one get the same problem ? how do you fix it?


Thank you
Wes
 
C

Cerebrus

Hi,

Does this work for you ?

ComboBox1.SelectedIndex = 0
ComboBox1.SelectedIndex = -1

I also see from your link that the problem is limited to Framework 1.0
version.

Regards,
Cerebrus.
 

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