combobox.SelectedIndex = -1 does not empty combobox

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top