Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I want to make a dictionary kind of windows application. I have a huge database with me. Now in my windows form I have a text box where user enter the word to search. I am confused how to achieve it. I did it the same in web application but by using ajax toolkit. it was AutoCompleteTextBox extender.

In windows application how we can achieve it??? Any suggestions please???

Thanks in advance..
Posted
Comments
Mohd Imran Saifi 6-Mar-12 9:15am    
use search option on your text_changed event
search in ur database

Use as
C#
public partial class empassetReport : Form
   {
       AutoCompleteStringCollection namesCollection =new AutoCompleteStringCollection();
       public static bool isOpen = false;

       public empassetReport()
       {
           InitializeComponent();
       }

       private void empassetReport_Load(object sender, EventArgs e)
       {
           isOpen = true;

           this.Location = new Point(150, 100);
           SqlDataReader dReader;
           SqlConnection conn =Db.GetConnection();
           //conn.ConnectionString = strConnection;
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandType = CommandType.Text;
           cmd.CommandText =
           "Select distinct(name) from empbirth" +
           " order by name asc";
           //conn.Open();
           dReader = cmd.ExecuteReader();
           if (dReader.HasRows == true)
           {
               while (dReader.Read())
                   namesCollection.Add(dReader["name"].ToString());

           }
           else
           {
               MessageBox.Show("Data not found");
           }
           dReader.Close();

           textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
           textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
           textBox1.AutoCompleteCustomSource = namesCollection;


       }

you can see also
winforms-autocomplete-textbox
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 10-May-12 1:46am    
My 5.
--SA
uspatel 10-May-12 1:52am    
Thanks....
Sergey Alexandrovich Kryukov 10-May-12 1:48am    
This is a new similar question:
http://www.codeproject.com/Questions/381519/Auto-Complete-Textbox

I references this answer. Would you like to add your own answer?

Thank you,
--SA
Refer to these past question:

Needs a text box that support Intellisense feature[^]
 
Share this answer
 
 
Share this answer
 
use select option on your text_changed event
search in ur database
/////////////////////////////////////

private void txt_query_TextChanged(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand("select * from Inquiry_Reg where serial_no='" + txt_query.Text.ToString() + "'", con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
string msvc = dr["MSVC"].ToString();//(use this line as your suggestion)
}
}
 
Share this answer
 
v2

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