usercontrols inside panels
In my project i added a usercontrol to a panel.when i try to add a new usercontrol to my panel i want to check what is the name of the usercontrol placed in the pa开发者_C百科nel before how to do it.
i have three different usercontrols, i assign it one by one to panel,before replacing the new one with the old one ,i want to find what is the old one inside the panel.
You can set the name like this:
Panel pnl= new Panel();
...
UserControl myControl = new UserControl();
myControl.Name = "muUserControl";
pnl.Controls.Add(myControl);
foreach (Control ctrl in pnlUserControlContainer.Controls)
{
if (ctrl is UserControl)
{
Console.WriteLine(ctrl.Name);
}
}
精彩评论