You are on page 1of 2

AUTO COMPLETAR Member 171 Points 47 Posts

Re: How to show data from sql server table to textbox autocomplete list in c#
Dec 23, 2012 08:01 AM|LINK

hi shamson here is code. public void loadData() { AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection(); string querry = @"Select distinct [Column] from [Table] order by [column] "; // make connection to databse and get data using datareader SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows == true) { while (dr.Read()) namesCollection.Add(dr["Column"].ToString()); } dr.Close(); txtBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend ; txtBox.AutoCompleteSource = AutoCompleteSource.CustomSource; txtBox.AutoCompleteCustomSource = namesCollection; }

Dec 23, 2012 01:12 PM|LINK


hi, I think it's problem with your textbox because I implemented the same code in my project and it's working .. also you can set these properties (like AutoCompleteMode) in the properties window of textBox have you get same error with outher textbox...? try to implement the code in completly new project... These are the namespace i used in my project using using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Data.SqlClient; System.Configuration;

You might also like