hi all
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 panel 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.
From stackoverflow
-
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); } }
0 comments:
Post a Comment