0

我有这个代码:

    private void button1_Click(object sender, EventArgs e)
    {

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

所以ComboBox的动作是通过点击button1来完成的。选择项目后是否可以立即采取行动?没有按钮点击?

4

2 回答 2

3

订阅SelectedIndexChanged活动

comboBox1.SelectedIndexChanged += OnSelectedIndexChanged;

private void OnSelectedIndexChanged(object sender, EventArgs e) {
  // Handle combo box changing
}
于 2013-04-03T22:14:15.580 回答
0

尝试使用此事件,

ComboBox1.SelectedIndexChanged

AutoPostBack = "true"

如果您想在选择项目后立即检查所选项目,请在您的标记中。

于 2013-04-03T22:17:14.127 回答