Click here to Skip to main content
15,896,514 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good day

I have created a Windows Form application with a combobox on the form.

I am reading the values from a dictionary into the combobox by using the click event of the combobox.

C#
private void cmbRplStatus_Click(object sender, EventArgs e)
      {
          dctRplStatus();
}


I have written the following code on the Index change event of the combobox

SQL
if (cmbRplStatus.Text == "Active")
           {
               MessageBox.Show("You clicked on Active");


The problem that I am having is, the moment I click on the combobox the message, "You clicked on active" automatically comes up, before I even clicked on active inside of the combobox.

What must I change so that when I click on "active" inside of the combox, then the message You clicked on active must show? Must I control the Index change of the combobox?
Posted
Updated 19-Mar-12 0:36am
v2

1 solution

You can use SelectedIndexChanged event of the ComboBox control for this purpose. An example is given here
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged(v=vs.100).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900