I want to change the text of a label based on the selection of a combobox:
Example:-
Combobox item: Fiction -----> Label text: Tale of two cities
Combobox item: Medicine -----> Label text: Snell's Anatomy
Combobox item: Histology -----> Label text: Basic Histology 5th Edition
Please help
AlanPosted Mar 7, 2008, 8:32 AM
If comboBox1 and label1 are your ComboBox and Label controls respectively, then try placing this code in the ComboBox's SelectedIndexChanged eventhandler:
private
void comboBox1_SelectedIndexChanged(object sender, EventArgs e){
switch (comboBox1.SelectedItem.ToString()){
case "Fiction":label1.Text =
"Tale of two cities"; break; case "Medicine":label1.Text =
"Snell's Anatomy"; break; case "Histology":label1.Text =
"Basic Histology 5th Edition"; break; default:label1.Text =
""; //say break;}
}
JohnPosted Mar 26, 2008, 7:16 AM
that was cool, didn't think of rolling out that way for output. How about instead of a label box, rolling into another combo box. ex. "Selected item in combobox1 generates list for combobox2"
**nm, figured out how to add items to combo box, but how do you remove items when you change your selection in the combobox?
HartoPosted Mar 7, 2008, 10:27 AM