I have an application that has 6 combo boxes in a groupbox. When one
combo box is selected and it's text properties are displayed, I want to
be able to reset the other combo boxes text property. How can this be
achieved??
The fact that they are all in one group box, to the best of my
knowledge, should not affect the answer. You want to set up a handler
for all six combo boxes' SelectedIndexChanged event. Within the event
handler, you need to unsubscribe for the other five combo boxes, because
otherwise they will fire a SelectedIndexChanged event as they refill
themselves.
The code in the constructor (or somewhere) will be something like this:
// repeat for each combo box
comboBox1.SelectedIndexChanged
+= new EventHandler(ComplexChangeHandler);
then the handler would be:
void ComplexChangeHandler (object sender, EventArgs e)
{
ComboBox cb = (ComboBox) sender;
// repeat for each combo box
comboBox1.SelectedIndexChanged
-= new EventHandler(ComplexChangeHandler);
// setup each of the other combo boxes' items. compare
// to 'cb' to see if this is the particular combo box.
// for example:
if (comboBox1 != cb) {ResetComboBox1();}
// Now reset all the handlers for selected index changed.
// repeat for each combo box
comboBox1.SelectedIndexChanged
+= new EventHandler(ComplexChangeHandler);
}