Click here to Skip to main content
15,843,145 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Auto complete textbox property in .net has the custom source was given in coding phase but it had to save new ones aromatically in the source at run time .I find the code but the new ones are saved until the app is open.and then we close and open it again it will not showing the new ones.
Posted
Updated 27-May-13 19:07pm
v2

1 solution

Properties those you have to set to the textbox :

AutoCompleteMode : Suggest Append
AuoCompleteSource : CustomSource

These properties must set to the textbox that to which textbox you want to set the AutoCompleteMode.
Then only the code will be performs.


Event: This code should write in Page_Load event.


SqlCommand cmd = new SqlCommand("select name from databasetable", con);
SqlDataReader dr = cmd.ExecuteReader();
AutoCompleteStringCollection col = new AutoCompleteStringCollection();
while (dr.Read())
{
col.Add(dr.GetString(0));
}

textBox1.AutoCompleteCustomSource = col;

I hope this code will help you.

and also other link for your reference

http://www.c-sharpcorner.com/uploadfile/tajwerj/dynamically-fill-autocomplete-textbox-from-datagridview/[^]
 
Share this answer
 
v2
Comments
KUMAR619 23-Oct-14 8:41am    
database have a string the code execute but i retrive integer error will be report
renish patel 28-Oct-14 5:10am    
Can you please put the error message or screen shot for it so, i can review it easily and provide feedback accordingly.
Abrar Kazi 30-Oct-14 11:05am    
I am not getting AutoCompleteCustomSource class in my project even though i have included System. Windows. Forms

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