C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Application windows, menus & toolbars »

Creating winforms AutoComplete TextBox using C# in Windows application


Posted Date: 03 Aug 2009    Resource Type: Code Snippets    Category: Application windows, menus & toolbars
Author: K'ranMember Level: Gold    
Rating: 1 out of 5Points: 10



Auto Complete Feature for Windows Textbox's



In this code Snippet I am explaining how to create AutoComplete Textbox in Windows Application using C#

Put this code in form_load




//creat auto complete Collection
AutoCompleteStringCollection collection = new AutoCompleteStringCollection();
//Connection String
string connectionString="your connection string";
//creating connection String
SqlConnection con = new SqlConnection(connectionString);
//open the connection
con.Open();
//get the data from database
SqlDataAdapter ad = new SqlDataAdapter("select sname from tbl_Student", con);
DataTable dt = new DataTable();
ad.Fill(dt);
if(dt.Rows.Count>0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//add the student name into auto complete collection
collection.Add(dt.Rows[i].ItemArray[0].ToString());
}
}
//after adding the student names into auto complete collection bind the collection to textbox
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
textBox1.AutoCompleteCustomSource = collection;



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Auto Complete for Window Applications  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Create your own Web Browser
Previous Resource: Title less Windows in WPF
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use