开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜