Dear all,
I have a form with 36 comboboxes, and I use this fucntion to update them:
private void controlBox(string boxName)
{
foreach (Control frmControl in this.Controls)
{
if (frmControl is ComboBox)
{
if (frmControl.Name == boxName)
{
ComboBox _bx = (ComboBox)frmControl;
_bx.Items.Clear();
_bx.Enabled = true;
_bx.Items.Add("It Works!");
}
}
}
}
My question is, what is the best way to pass the boxName string to this funtion when a box has a selected item.
Let me explain better, when I select an item on box1, it should call the funtcion controlBox("box2"), so it will enable box2 and add the items I want (it will be an query associated with the selected value from box1).
+-------+-------+-------+
| box1 | box2 | box3 |.....
But my problem is, I have 36 comboboxes, so if I use the simplest way I´ll have 36 events handler like:
this.Indice11.SelectedIndexChanged += new System.EventHandler(this.Indice11_SelectedIndexChanged);
and a function Indice11_SelectedIndexChanged calling controlBox(....) .
Is there any kind of event that detects when a combobox on the form is changed and gets it´s name? or I´ll have to do the 36 events handlers?
Thanks,
Fernando França