标签:visible dip 仓库 form toolstrip menu led color nbsp
MDI容器 具体步骤如下: private void 销售ToolStripMenuItem_Click(object sender, EventArgs e) { VisibledForm(); Form2 f2 = new Form2(); 打开新窗口 f2.MdiParent = this; f2.Name = "f2"; OpenForm(f2); } private void VisibledForm() { foreach (Control c in panel1.Controls) { if (c is Form) { c.Visible = false; } } } private void 仓库ToolStripMenuItem_Click(object sender, EventArgs e) { VisibledForm(); 引用方法 Form3 f3 = new Form3(); f3.MdiParent = this; f3.Name = "f3"; OpenForm(f3); } private void 财务ToolStripMenuItem_Click(object sender, EventArgs e) { VisibledForm(); 引用方法 Form4 f4 = new Form4(); f4.MdiParent = this; f4.Name = "f4"; OpenForm(f4); } //传一个窗体对象过来,看看有没有打开,如果开打了,则还原已打开的窗口 //如果未打开,则打开此新窗口 //参数:要验证的窗体 //返回值:无 public void OpenForm(Form fff) Form的参数fff,创建方法OpenForm { bool has = false; foreach (Control c in panel1.Controls) { if (c is Form) 如果这个控件是窗口 { if (c.Name == fff.Name) { has = true; 如果走到这说明有 fff = c as Form; } } } VisibledForm(); if (has) 然后进行判断 { //fff.WindowState = FormWindowState.Maximized; 按说应该进行还原窗口,但是,这里如果还原的话,这一步并不会走,所以不用这一步,而是直接Show出来 fff.Show(); } else 如果这个窗口没有打开,然后Show出来,也需要调取隐藏的方法,所以把这个方法写到外边 { fff.Parent = panel1; fff.Show(); } } private void Form1_Load(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.MdiParent = this; f2.Name = "f2"; OpenForm(f2); }
标签:visible dip 仓库 form toolstrip menu led color nbsp
原文地址:http://www.cnblogs.com/yunpeng521/p/7215946.html