标签:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _7._1练习
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 销售模块ToolStripMenuItem_Click(object sender, EventArgs e)
{
bool has = false;
Form2 f2 = new Form2();
foreach (Form f in panel1.Controls)
{
if (f.Name == f2.Name)//窗口只打开一次
{
has = true;
f.Show();
f2.Close();
}
}
if (has)
{
foreach (Form f in panel1.Controls)
{
if (f.Name != f2.Name)
{
f.Hide();//相同命名自动隐藏
}
}
}
else
{
f2.WindowState = FormWindowState.Maximized;//窗口最大化
f2.MdiParent = this;//mdi 父集是form1
f2.Parent = panel1;// 父集是form1 里的 panel1
f2.Show();
}
}
private void 仓库模块ToolStripMenuItem_Click(object sender, EventArgs e)
{
bool has = false;
Form f3 = new Form3();
foreach (Form f in panel1.Controls)
{
if (f.Name == f3.Name)////窗口只打开一次
{
has = true;
f.Show();
f3.Close();
}
}
if (has)
{
foreach (Form f in panel1.Controls)
{
if (f.Name != f3.Name)
{
f.Hide();////相同命名自动隐藏
}
}
}
else
{
f3.WindowState = FormWindowState.Maximized;////窗口最大化
f3.MdiParent = this;//mdi 父集是form1
f3.Parent = panel1;// 父集是form1 里的 panel1
f3.Show();
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
}
}
标签:
原文地址:http://www.cnblogs.com/suiyuejinghao123/p/5636324.html