开发者

How to remove user control from dock panel

RoomDiagram rd = new RoomDiagram();
maincDockPanel.Children.Remove(rd);

when i wrig开发者_运维问答ht this nothing happens. how i can remove child and then add new one? thanks


If you need to remove then you have to use dockPanel1.Children.RemoveAt() because Children is UIElement Collection you may write a small code to ietrate over the collection and see if it is your required control to remove then remove it similarly dockPanel1.Children.Add() to add UIElement same should be the case if you are using UserControl

some sample code to Iterate over collection and will show you the name of the controls

 foreach (Control x in dockPanel1.Children)
        {
            MessageBox.Show(x.Name);
        }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜