Hi AJLawson
We have done some test on your case and found it was not easy to do. The only solution I have found was to control by its name from the unit.Name. The unit.Name is a string contains the operation and the control name. So I used the String.Split method to get the control name.
Code Snippet
[] s = unit.Name.Split(' ');
controlName = s[1];
The second string is the control name.
Then get the control by name.
Code Snippet
frm = new YourForm();
Control ctrl;
for (int i = 0; i < frm.Controls.Count; i++)
{
if (frm.Controls[i].Name == controlName)
{
ctrl = frm.Controls[i];
break;
}
}
(ctrl.Tag != null)
{
if (ctrl.Tag.ToString() == "RootControl")
{
return;
}
}
So you need to set the tag of the control to “RootControl�if this control is your root control. This solution seems not good enough, but it is the only one I can found till now.
Sincerely,
Kira Qian |