gpt4 book ai didi

.net - 我怎么知道用户是否在ComboBox中更改了Selected Item?

转载 作者:行者123 更新时间:2023-12-01 05:24:22 25 4
gpt4 key购买 nike

问题在于,当用户进行更改以及由应用程序代码设置SelectedItem进行更改时,都会调用SelectedIndexChanged事件。

是否有办法判断用户是否通过鼠标或键盘的直接操作更改了该项目?

最佳答案

试试这样的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();
}
}

关于.net - 我怎么知道用户是否在ComboBox中更改了Selected Item?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11797544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com