question about comboBox

  • Thread starter Thread starter Claudia Fong
  • Start date Start date
C

Claudia Fong

Hi,


I would like to know if is possible to "know" which is the
comboBox.SelectedIndex without "clicking any button".

I used this
int selectedIndex = comboBox2.SelectedIndex; to get the index, but it
only works if this code is inside a button1_Click.

What I would like to do is when I select an item in the combobox, it
will show me an information for example.


Cheers!

Claudi
 
Claudia Fong said:
Hi,


I would like to know if is possible to "know" which is the
comboBox.SelectedIndex without "clicking any button".

I used this
int selectedIndex = comboBox2.SelectedIndex; to get the index, but it
only works if this code is inside a button1_Click.

What I would like to do is when I select an item in the combobox, it
will show me an information for example.

Handle the SelectedIndexChanged or SelectedValueChanged event on the combo
box, you can then write whatever code you need and it will be executed
whenever the index or value changes.
 
I handle the comboBox2_SelectedIndexChanged; but it still doesn't work
:(


private void comboBox2_SelectedIndexChanged(object sender,
System.EventArgs e)
{
int selectedIndex = comboBox2.SelectedIndex;
if (selectedIndex != 0)
{
MessageBox.Show("Changed");
}

}

No matter what I selected from the comboBox, it never show the
messagebox...


Claudi
 
Back
Top