Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I took one combobox having id=comboBox and one textBox having ID=textBox.Now i want to control the value of textBox by selection of comboBox value using c# and SQl.
Posted
Comments
Sandeep Mewara 9-Mar-11 2:06am    
go ahead do it. Whats the issue?

Okay. Here is the hint:
Look/read on this event: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged.aspx[^]

You need to write something related to combobox selected item data into textbox in this event.

Try!
 
Share this answer
 
Comments
Banajyotsna 9-Mar-11 7:11am    
Sir i tried this coding but i could not able to succeed.Can u give another method to solve this problem in window based?
Sandeep Mewara 9-Mar-11 8:07am    
This is *the* method! :doh:
Sergey Alexandrovich Kryukov 28-Mar-11 23:46pm    
This is a good answer, my 5.
--SA
Hi
Sir

i have a problem with combobox

i have a client data, in combobox if i select client then it must show rest detail in the text box like tel no, cell no, email.

could you please helpe me how to do
 
Share this answer
 
Comments
Banajyotsna 27-Aug-11 2:17am    
i am giving one example

form1_load
{
SqlDataAdapter ad=new SqlDataAdapter("select *from reg",con);
DataSet ds=new DataSet();
ad.Fill(ds,"reg");
comboBox1.DataSource=ds.Tables["reg"].DefaultView;
comboBox1.DisplayMember="name";
comboBox1.ValueMember="name";
}
private void comboBox1_SelectedIndexChanged()
{
SqlDataAdapter addd=new sqldataadapter("select *from reg where name='"+comboBox1.SelectedValue.ToString()+"'",con);
DataSet dss=new DataSet();
ad.fill(dss,"reg");
if(dss.Tables["reg"].Rows.Count>0)
{
textBox1.Text=dss.Tables["reg"].Rows[0]["telno"].ToString();
}
else
{
textBox1.Text="";
}
}
it is working finely try it.
Member 9115849 15-Jun-12 13:29pm    
Thx man

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900