I'm trying to put dynamicaly a LinkLabel (also I traied to put a button) in a TabPage:
LinkLabel newLinkLabelButton = new LinkLabel();
newLinkLabelButton.Text = "Login";
newLinkLabelButton.Name = "linkLabel_11";
tabs.TabPages[0].Controls.Add(newLinkLabelButton);
Now I'm trying to find this control on the specificf TabPage with function
newLoginLinkLabel = (LinkLabel)Helper.GetLinkLabelByTagAndfamily(tabs.TabPages[0], _name);
where the function body is:
public static Control GetControlByTagAndfamily(TabPage _tab, string _name)
{
Control rez = new Control();
foreach (Control ctrl in _tab.Controls)
{
if (ctrl.Name == _name)
{
rez = ctrl;
break;
}
}
return rez;
}
But the function never founds a LinkLabel or a Button inside _tab.Controls collection. I observed the collection contains founds Labels only, if I trying to find some labels inside.
Pleas help to solve this.