WinForms ComboBox下拉和自动完成窗口都出现 [英] WinForms ComboBox DropDown and Autocomplete window both appear
问题描述
我在winforms应用程式中有一个 ComboBox
:
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:
- 单击
ComboBox
下拉按钮 - 显示项目列表,并选择ComboBox
- 键入'5','1'...例如,我正在使用自动填充功能搜索515,516等。 >
- 您会看到自动完成窗口现在显示在下拉列表的顶部。但是,如果我将鼠标悬停在其上,则是接收鼠标事件(包括点击)的自动完成窗口后面的模糊下拉窗口。所以我想我点击了一个自动完成项目,但实际上点击了完全随机,我看不到的东西。
- Click the
ComboBox
drop down button -- this displays the list of items and selects the text in theComboBox
- Type '5', '1' ... i.e. I'm looking to use autocomplete to search for 515, 516, etc.
- You'll see that the autocomplete window now appears ON TOP of the drop down list. However if I mouse over, it's the obscured drop down window behind the autocomplete window that's receiving the mouse events, including the click. So I think I'm clicking on an autocomplete item but actually clicking on something totally random that I can't see.
ComboBox
中的错误?我使用Windows 7如果这很重要。我是否以某种方式配置 ComboBox
Is this a bug in the ComboBox
? I'm using Windows 7 if that matters. Am I configuring the ComboBox
wrong somehow?
请注意,使用KEYBOARD使用自动完成下拉菜单。因此,上/下箭头键正在使用前窗口,但鼠标正在使用后窗口。
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.
这是反馈文章。如上所述,Microsoft不考虑修复。一种可能的解决方法是在DropDown事件处理程序中禁用自动完成功能,并在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 ComboBox下拉和自动完成窗口都出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!