ComboBox中的自动完成功能问题(DropDownList) [英] Problem with AutoComplete feature in ComboBox (DropDownList)

查看:55
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆