user1391111
user1391111

Reputation: 63

Action immediately after selecting Item

I have this code:

    private void button1_Click(object sender, EventArgs e)
    {

        if (comboBox1.SelectedItem.ToString() == "blahblah")
        {
            processing ps = new processing();
            pictureBox1.Image = ps.blahblah(bmp);
        }
        else
        {...
        }
    }

So the action of the ComboBox is done by clicking on the button1. It is possible to take action immediately after selecting Item? without button clicking?

Upvotes: 0

Views: 2874

Answers (2)

kabichan
kabichan

Reputation: 1093

Try using this event,

ComboBox1.SelectedIndexChanged

and do

AutoPostBack = "true"

in your mark up if you want to check the selected item immediately after selecting item.

Upvotes: 0

JaredPar
JaredPar

Reputation: 755587

Subscribe to the SelectedIndexChanged event

comboBox1.SelectedIndexChanged += OnSelectedIndexChanged;

private void OnSelectedIndexChanged(object sender, EventArgs e) {
  // Handle combo box changing
}

Upvotes: 3

Related Questions