Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.33/5 (3 votes)
See more:
hello friend,

hello friend i want search box like google and youtube in which automatic suggestion comes out when we type in textbox.

can any one guide me how i can do this task.
Posted

 
Share this answer
 
Hello Dear
you can use from these properties of TextBox
AutoCompleteCustomSource,
AutoCompleteMode,
AutoCompleteSource
if you want to have a custom source do these
this.textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
each string that you want to be in history of textbox just add it to AutoCompleteCustomSource of textbox
if you have a looking on help of VS about these properties you cab see more.
 
Share this answer
 
Comments
Sandeep Mewara 29-Jun-11 6:47am    
He is talking of Web(ASP.NET) and not Winforms.
You can use AJAX to acheive this.

1) Use webservice and the webmethod of that webservice will return in form of xml data that is queried from database.

2) On keypress event of the textbox you will call the webservice using java script.

3) Use java script to fill the listbox like control by the xml data parsed in list like format just below the textbox.

For more details you can refer http://www.iansuttle.com/blog/post/Applying-AJAX-Using-ASPNET-11.aspx[^]
 
Share this answer
 
Comments
BobJanova 29-Jun-11 6:30am    
Good answer, however, it is good practice not to make the web service call on keypress, but instead to run an idle timer of say 200 ms, so that when the user is typing rapidly you do not cause a lot of unnecessary requests.

Personally I'd say that XML is overkill for this. I tend to return content with one list box entry per line.
thanks friend my problem is sortout but i am forget the link by which i am sortout my problem if i got it then i will share with u
 
Share this answer
 
Comments
Shailesha03 16-Jul-11 8:03am    
If U Got that Link Then Please Share It.
Or can U show, That how U have Done

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900