检查用户控制是否已经打开
我正在使用winform c# 有主化有一个面板。我的库存和销售用户控件正在面板中打开。面板1.controls.add(库存); 如何检查UserControls是否打开? 当我检查它时,我想添加TabControl。但是我不知道如何在不关闭用户控件的情况下添加TABPAGE控件。谢谢
Im using WinForm C#
Have MainForm there is one panel where. my Inventory and Sell user controls are opening in panel. panel1.Controls.Add(inventory);
How to check if userControls are open?
When i check it i want to add tabControl. But i dont know how to add in tabPage controls without closing user control. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何在您不知情的情况下将用户控件添加到
panel1.Controls
中?而且如果你自己添加的话,你应该已经知道用户控件的名称了。因此,您所要做的就是循环访问
panel1.Controls
中的控件,看看是否找到您的用户控件。例如:或者,如果您出于某种原因不知道控件的名称,您仍然可以找到已添加到
UserControl
类型的所有控件。面板的控件集合。像这样:记住
Tag<每个控件上提供的 /code> 属性
为您提供了一种唯一标识它的方法。如果您不知道名称,也可以检查该属性是否匹配。
How could the user control possibly be added to
panel1.Controls
without you knowing it? And if you added it yourself, you should already know the name of the user control.Thus, all you have to do is loop through the controls in
panel1.Controls
and see if you find your user control. For example:Alternatively, if you for whatever reason don't know the name of the control, you could still find all the controls of type
UserControl
that have been added to the panel's Controls collection. Like so:Remember that the
Tag
property provided on every control gives you a way to uniquely identify it. You can check that property for matches, too, if you don't know the name.不确定打开是什么意思,但您可以处理 Panel 类上的
ControlAdded
事件以在添加控件时捕获...Not sure what you mean by open, but you can handle the
ControlAdded
event on the Panel class to capture when a control is added...