comboBox SelectedIndex Changed
Posted on 2008-10-07
I am working on Winform comboBox
I want the control to enter selectedIndexChanged_Event only if an item is selected from comboBox.
ComboBox is bound to a dataset
Even though i put these statements when the form loads it gets inside the event. ... ComboBox index starts with 0(zero) when I select
first item in combo the selected index is Zero
if (combobox1.SelectedIndex > -1 && combobox1.SelectedValue.ToString() != string.Empty)
How can I control this.
currently I have combo box bound this way
this.cboCategory.DataSource = _ds.Tables;
this.cboCategory.DisplayMember = "Student_Name";
this.Combobox1.ValueMember = "student_ID";
this.Combobox1.SelectedIndex = -1;
this.Combobox1.SelectedIndexChanged += new System.EventHandler(this.Combobox1_SelectedIndexChanged);