Easy Recipe
- Create a winform application
- add two text boxes
- add one combo box
- add two buttons
Step One: Give the combo box a few values (ex: Car, Truck and Motorcycle)
Step Two: Code The button1 click event. Double click on button1 to create the button1 click event. You should see the following
private void button1_Click(object sender, EventArgs e)
{
}
Now code the button1 event with
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = comboBox1.Text;
}
Step Three: Code the button2 click event. Double click on button2 to create the button2 click event. You should see the following
private void button2_Click(object sender, EventArgs e)
{
}
Now code the button 2 event with
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = comboBox1.Text;
}
Now take her for a spin. Click on your combo box and select a value. Once your value has been selected, click on button 1 to populate the
textbox1
. Click on your combo box and choose another value. Once your value has been selected, click on button 2 to populate
texbox2
.
This technique makes it easy for users to fill in multiple text boxes from a single combo box stuffed with preset values.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.