开发者

how to create textbox for searching like Google textbox style

Just as simple as this, I need to search an array that is binded to listbox, and user will type the text in a text box, something like Google search text box does.

This is for Windows Applica开发者_如何学JAVAtion using C# (3.5)

Any idea?


You need to use ComboBox, it has autocomplete

This is simple


WinForms TextBox controls have an AutoComplete property. This behaves the same as the Google TextBox. Here is an example:

http://csharpdotnetfreak.blogspot.com/2009/01/winforms-autocomplete-textbox-using-c.html


Assuming the array is sorted in alphabetical order.

Just handle the TextChanged event for the TextBox and whenever it changes you use ListBox.FindString to find the first item in the ListBox that starts with that string and then call ListBox.TopIndex with the index of that item to make that be the top visible item in the ListBox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜