码迷,mamicode.com
首页 > Windows程序 > 详细

MDI 窗体

时间:2016-07-03 00:30:46      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

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)
{

}
}
}

MDI 窗体

标签:

原文地址:http://www.cnblogs.com/suiyuejinghao123/p/5636324.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!