Mark
Mark

Reputation: 13

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 Application using C# (3.5)

Any idea?

Upvotes: 1

Views: 6108

Answers (3)

Adam Houldsworth
Adam Houldsworth

Reputation: 64527

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

Upvotes: 1

Denis Palnitsky
Denis Palnitsky

Reputation: 18387

You need to use ComboBox, it has autocomplete

This is simple

Upvotes: 3

Hans Olsson
Hans Olsson

Reputation: 55049

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.

Upvotes: 0

Related Questions