隐藏/显示MdiChilds
本文关键字:MdiChilds 显示 隐藏 | 更新日期: 2023-09-27 18:05:12
我有一个mdi应用程序。我有在父一些链接,其中,当单击打开一个新的子窗体,并隐藏一个已经打开如何查看child是否已打开?
A little scenario:
link 1 -> opens Child of type A
link 2 -> opens Child of type B
link 3 -> open Child of type C
Application start:
click on link 1-> check if a child of type A is opened
- yes -> hides the current opened child and shows the A-type Child
- no: -> hides the current opened child and creates a new A-type child and shows it
click on link 2 -> check if a child of type B is opened
- yes -> hides the current opened child and shows the B-type Child
- no: -> hides the current opened child and creates a new A-type child and shows it
etc..
你能帮我写一些代码吗?
谢谢你…
更新:
像这样的?
foreach (Form aForm in this.MdiChildren)
{
aForm.Hide();
}
foreach (Form f in this.MdiChildren)
{
if (f.Name == "VizualizareArticol")
f.Show();
else
{
VizualizareArticol vv = new VizualizareArticol();
vv.MdiParent = this;
vv.StartPosition = FormStartPosition.Manual;
vv.Location = new Point(0, 0);
vv.Show();
}
}
检查是否为Control.Visible。如果项目是可见的,你可以隐藏它,如果它不可见。否则,请查看您创建的对象。
如果你已经创建了一个表单并隐藏了它,它就不可见了。因此,您可以检查. visible并显示表单。
if(null != aForm && !aForm.Visible){
aForm.Show()
aForm.BringToFront();
}else if(null == aForm){
// create the form
}
// otherwise form is existing & visible