ComboBox.SelectedIndex将触发SelectedIndexChanged事件,有没有办法从代码触发ComboBox的SelectionChangeCommitted?
public Form1()
{
InitializeComponent();
string[] cb_items = { "A", "B", "C" };
comboBox1.Items.AddRange(cb_items);
comboBox1.SelectedIndex = 1;
// what code will trigger comboBox_SelectionChangedCommitted from here?
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// triggered by comboBox1.SelectedIndex = 1
textBox1.Text = "Selected " + comboBox1.SelectedItem;
}
private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
{
textBox1.Text = "Committed " + comboBox1.SelectedItem;
}
答案 0 :(得分:0)