Guys explained right, you can also see this solution me
You can have only one handler, like this for all your control:
foreach (Control ctrl in this.Controls)
{
if (ctrl.GetType() == typeof(UniControl))
{
temp = (UniControl)ctrl;
temp.Operate += new UniControl.OperateEventHandler(temp, control_operate);
}
}
Then into this event function, manage controls easily;)
void control_operate(object sender, OperateEventHandler e)
{
switch ((sender as yourControlType).Tag.ToString())
{
case "Control0":
break;
case "Control1":
break;
case "Control2":
break;
.
.
.
case "Controln":
break;
default:
break;
}
}
I think you have 2 way:
1. If controls does same work:
void control_operate(object sender, OperateEventHandler e)
{
(sender as yourCntType).Enabled = false;
}
2. O.W. If controls doesn't same work, you write all states exactly (write all cases):
void control_operate(object sender, OperateEventHandler e)
{
switch ((sender as yourControlType).Tag.ToString())
{
case "Control0":
break;
case "Control1":
break;
case "Control2":
break;
case "Control3":
break;
default:
break;
}
}