'自己加个listbox控件来隐藏起来,在combobox的change事件加入代码。
private sub combo1_change()
dim tempstr As String
list1.clear
list1.left=combo1.left
list1.top=combo1.top+combo1.height
list1.width=combo1.width
list1.Visible = True
tempstr = combo1.text
for i = 0 to combo1.listcount - 1
if instr(1, left(combo1.list(i), len(tempstr)), tempstr) <> 0 then list1.additem combo1.list(i)
next i
end sub
'list1的click事件中加入代码
private sub list1_click()
combo1.text=list1.text
list1.visible=falst
end sub
当然,随手写的。代码还有待完善。可能有错误,但思路绝对是好的
ComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
ComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;