开发者

usercontrols inside panels

开发者 https://www.devze.com 2022-12-27 17:56 出处:网络
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

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);
                    }
                }
0

精彩评论

暂无评论...
验证码 换一张
取 消