Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi... i am doing a windows application project...i have doubt in autocomplete textbox method.

there is one textbox
when i type on textbox i need to show name and phone no. using auto complete....right now name is working but phone number of particular name is not displaying.....is any possible to show two data in single textbox using auto complete textbox....
Posted

 
Share this answer
 
Comments
ANOOP CL NAIR 2-Mar-12 6:04am    
actually i can display name...but i need to display name with phone number...is any possible way to display?????
uspatel 2-Mar-12 6:58am    
you can merge in query name+phonenumber.......
ANOOP CL NAIR 2-Mar-12 10:11am    
i am doing like this but phone number is not displaying......


MySqlConnection myConnection = new MySqlConnection(@"Server=localhost;user id=root;password=headway123;database=physiotheraphy");
myConnection.Open();

MySqlCommand cmd = new MySqlCommand("SELECT patient_name+phone_no FROM patient", myConnection);
DataSet ds = new DataSet();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(ds, "My List");


AutoCompleteStringCollection col = new AutoCompleteStringCollection();
int i = 0;
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
col.Add(ds.Tables[0].Rows[i]["patient_name "].ToString());
// col.Add(ds.Tables[0].Rows[i]["phone_no"].ToString());
}

txtname.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtname.AutoCompleteCustomSource = col;
txtname.AutoCompleteMode = AutoCompleteMode.Suggest;

myConnection.Close();
uspatel 3-Mar-12 0:36am    
MySqlCommand cmd = new MySqlCommand("SELECT CONCAT(patient_name,phone_no) as NamewithNo FROM patient", myConnection);
DataSet ds = new DataSet();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(ds, "My List");


AutoCompleteStringCollection col = new AutoCompleteStringCollection();
int i = 0;
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
col.Add(ds.Tables[0].Rows[i]["NamewithNo"].ToString());
// col.Add(ds.Tables[0].Rows[i]["phone_no"].ToString());
}

txtname.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtname.AutoCompleteCustomSource = col;
txtname.AutoCompleteMode = AutoCompleteMode.Suggest;

myConnection.Close();
ANOOP CL NAIR 3-Mar-12 1:48am    
thanks a lot....
A simple...C# Autocomplete Textbox

Kerry
 
Share this answer
 

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