ComboBox中的自动完成功能问题(DropDownList) [英] Problem with AutoComplete feature in ComboBox (DropDownList)
问题描述
我在ComboBox(DropDownList)中的自动完成功能存在以下问题。我的组合设置:
AutoCompleteMode:AutoCompleteMode.Append
AutoCompleteSource:AutoCompleteSource.ListItems
DropDownStyle: ComboBoxStyle.DropDownList
项目:{" 40"," 41"," 42"" 43"}
现在再现步骤:
焦点和弹出(!)组合框,键入'42'(首先选择'40',然后选择'42' - 这很好)然后按Tab键 - 值' 40'被恢复...没有更改值或索引的事件被触发..在调试时我看到在组合框上,离开事件值仍然是
'42',但是在DropDownClosed事件中它被切换回'40'。两者之间没有任何东西被解雇。
这是一个已知问题以及如何处理它?</ p>
Thanx,
Linas
Linas Mikutaitis
尝试这样做:
公开 Sub 新()
InitializeComponent()
comboBox1.DataSource = array
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
comboBox1.AutoCompleteCustomSource = 新 AutoCompleteStringCollection()
comboBox1.TextChanged + = 新 EventHandler( AddressOf comboBox1_TextChanged)
End Sub
私有 Sub comboBox1_TextChanged(发件人正如 对象,e As EventArgs)
Dim text As String = comboBox1.SelectedItem.ToString ()
MessageBox.Show(text)
End Sub
Hi,
I have the following problem with AutoComplete feature in ComboBox (DropDownList). My settings for combo:
AutoCompleteMode: AutoCompleteMode.Append
AutoCompleteSource: AutoCompleteSource.ListItems
DropDownStyle: ComboBoxStyle.DropDownList
Items: {"40","41","42","43"}
Now reproduction steps:
Focus and Popup (!) ComboBox, type '42' (at first '40' is selected, then '42' - which is fine) and then press Tab - value '40' is restored... no events of the value or index changed fired.. While debugging I see that on combobox Leave event value is still '42', but on DropDownClosed event it's switched back to '40'. Nothing is fired in between.
Is it a known issue and how to deal with it?
Thanx,
Linas
Linas Mikutaitis解决方案Try to do it this way:
Public Sub New() InitializeComponent() comboBox1.DataSource = array comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource comboBox1.AutoCompleteCustomSource = New AutoCompleteStringCollection() comboBox1.TextChanged += New EventHandler(AddressOf comboBox1_TextChanged) End Sub Private Sub comboBox1_TextChanged(sender As Object, e As EventArgs) Dim text As String = comboBox1.SelectedItem.ToString() MessageBox.Show(text) End Sub
这篇关于ComboBox中的自动完成功能问题(DropDownList)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文