问题是当用户进行更改时以及应用程序代码设置SelectedItem进行更改时,都会调用SelectedIndexChanged事件。
有没有办法通过用户从鼠标或键盘直接操作来判断项目是否已更改?
答案 0 :(得分:1)
尝试类似SelectedChangeCommitted MSDN
的内容private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
{
ComboBox comboBox = (ComboBox) sender;
// Change the length of the text box depending on what the user has
// selected and committed using the SelectionLength property.
if (comboBox.SelectionLength > 0)
{
textbox1.Width =
comboBox.SelectedItem.ToString().Length *
((int) this.textbox1.Font.SizeInPoints);
textbox1.Text = comboBox.SelectedItem.ToString();
}
}