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)
{
}
}
}
转载于:https://www.cnblogs.com/suiyuejinghao123/p/5636324.html
今天的文章MDI 窗体分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/29939.html