如何从扩展坞面板中删除用户控件 [英] How to remove user control from dock panel

查看:68
本文介绍了如何从扩展坞面板中删除用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



当我怀特时,这什么也没有发生.我如何删除孩子然后添加新孩子?感谢



when i wright this nothing happens. how i can remove child and then add new one? thanks

推荐答案

,您正在创建RoomDiagram类的新实例,然后尝试将其删除.所以它不起作用.

试试

you are creating the new instance of the RoomDiagram class and then trying to remove it. So it is not working.

Try

maincDockPanel.Children.Clear();
maincDockPanel.Children.Add(new UserControl2());



它将删除DockPanel的所有子元素.如果要删除特定的控件,请使用控件的ID.



It will remove all the child elements of the DockPanel. If you want to remove the specific one then use the ID of the control.

maincDockPanel.Children.Remove(ControlID);


这篇关于如何从扩展坞面板中删除用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆