Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a combobox inside it some value I want when I select a specific value from it another text box it's visible become true depends on the value which I will choose from the combobox
Posted
Comments
LanFanNinja 6-Feb-12 1:26am    
Check swapnilKumbhar's comment to my solution maybe it will help you.

1 solution

Something like this??
C#
itemsComboBox.Items.Add("Dog");
itemsComboBox.Items.Add("Cat");
itemsComboBox.Items.Add("Pig");

private void itemsComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
    switch ((string)itemsComboBox.SelectedItem)
    {
        case "Dog":
            testTextBox.Visible = true;
            break;

        case "Cat":
            break;

        case "Pig":
            break;
    }
}


Does that help?
 
Share this answer
 
Comments
Sarah Mohammed77 5-Feb-12 16:07pm    
if the combobox binding from the database???
and there is display member and value member
LanFanNinja 5-Feb-12 16:43pm    
Sorry I missed the SQL tag. I really have never messed with databases that much so I do not know how to answer your question.

I am sure someone else will be by shortly to help you out but if I find out the answer I will let you know.

Sorry. :(
swapnilKumbhar 6-Feb-12 1:23am    
//Declare Conn,Cmd,dr 1st
//Retrieve Data from Database to Combo Box
string qr = "select * from TableName";
con = new MySqlConnection(ConStr);
con.Open();
cmd = new MySqlCommand(qr, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
cmbBox.Items.Add(dr[0].ToString());
}
//On TextChanged Event Of CmbBox
private void cmbBox_TextChanged(object sender, EventArgs e)
{
if(cmbBox.Text=="Whatever_Value")
txtBox1.Visible=True;
So on...
}

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