的WinForms组合框下拉列表和自动完成窗口同时出现 [英] WinForms ComboBox DropDown and Autocomplete window both appear
问题描述
我已经有了这个code WinForms应用程序的组合框:
I've got a combobox on a winforms app with this code:
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
DataTable t = new DataTable();
t.Columns.Add("ID", typeof(int));
t.Columns.Add("Display", typeof(string));
for (int i = 1; i < 2000; i++)
{
t.Rows.Add(i, i.ToString("N0"));
}
comboBox1.DataSource = t;
comboBox1.ValueMember = "ID";
comboBox1.DisplayMember = "Display";
我然后按照下列步骤操作窗口打开时:
I then follow these steps when the window opens:
- 单击组合框下拉按钮 - 这显示项目的列表,并选择在下拉列表 正文
- 键入'5','1'...即我期待使用自动完成搜索515,516,等等。
- 您会看到自动完成窗口现在出现在下拉列表的顶部。但是,如果我鼠标,它是模糊的下拉了正在接受鼠标事件,包括点击自动完成窗口后面的窗口。所以,我觉得我点击自动完成的项目,但实际上点击的东西完全随机的,我不能看到的。
这是在ComboBox的错误吗?我使用Windows 7如果该事项。我在配置组合框错不知何故?
Is this a bug in the ComboBox? I'm using Windows 7 if that matters. Am I configuring the ComboBox wrong somehow?
另外,在使用键盘采用的自动完成下拉。因此上/下箭头键所使用的前窗,但鼠标使用后窗
Note also that using the KEYBOARD uses the autocomplete drop down. So up/down arrow keys are using the front window, but the mouse is using the back window.
推荐答案
没有问题,获取此一个摄制只需设定从PropertyGrid中的属性。行为这种方式无论是在Win7和Windows XP中。
No problem getting a repro for this simply by setting the properties from the PropertyGrid. Behaves this way both in Win7 and Windows XP.
这是正常的行为在这个<一个记录href=\"https://connect.microsoft.com/VisualStudio/feedback/details/254605/combobox-autocomplete-mouse\">feedback文章。如上所述,微软不考虑修复。一个可能的解决方法是在下拉事件处理程序禁用自动完成,并在DropDownClosed事件处理程序重新启用它。
This is broken behavior documented in this feedback article. As indicated, Microsoft is not considering a fix. One possible workaround is to disable autocomplete in a DropDown event handler and re-enable it in a DropDownClosed event handler.
这篇关于的WinForms组合框下拉列表和自动完成窗口同时出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!