zoukankan      html  css  js  c++  java
  • MDI窗体

    将窗体属性里面IsMdiContainer的值改为true

    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 mdichuangti
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void label1_Click(object sender, EventArgs e)
            {
    
            }
            
            private void 销售模块ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                bool has = false;
                Form2 f2=new Form2();
                f2.WindowState = FormWindowState.Maximized;//开启窗口最大化
                foreach (Form f in this.MdiChildren)
                {
                    if (f.Name == f2.Name)//判断集合中是否有该窗体
                    {
                        has = true;//记录一下含有该窗体
                        f.Show();//已经打开的窗体继续显示
                        f2.Close();//关闭新建窗体
                    }
                }
                if (has)//如果有该窗体
                {
                    foreach (Form f in this.MdiChildren)
                    {
                        if (f.Name != f2.Name)
                        {
                            f.Hide();//其余窗体都隐藏
                        }
                    }
                }
                else//如果没有该窗体
                {
                    f2.MdiParent = this;//将f2窗体放入mdi窗体中
                    f2.Show();//显示该窗体
                }
    
            }
    
            private void 仓库模块ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                bool has = false;
                Form3 f3 = new Form3();
                f3.WindowState = FormWindowState.Maximized;
                foreach (Form f in this.MdiChildren)
                {
                    if (f.Name == f3.Name)
                    {
                        has = true;
                        f.Show();
                        f3.Close();
                    }
                }
                if (has)
                {
                    foreach (Form f in this.MdiChildren)
                    {
                        if (f.Name != f3.Name)
                        {
                            f.Hide();
                        }
                    }
                }
                else
                {
                    f3.MdiParent = this;
                    f3.Show();
                }
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
    }

    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 mdichuangti
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
    
    
            private void Form2_Load(object sender, EventArgs e)
            {
    
            }
        }
    }

    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 mdichuangti
    {
        public partial class Form3 : Form
        {
            public Form3()
            {
                InitializeComponent();
            }
    
            private void Form3_Load(object sender, EventArgs e)
            {
    
            }
        }
    }

  • 相关阅读:
    java类加载全过程
    pyAggr3g470r 3.6 发布,新闻聚合器
    fourinone分布式协调设计解析
    修改openJDK7的javac,使得java支持单引号字符串
    SabreDAV 1.8.0 发布,集成 WebDAV 系统
    openSUSE 12.3 里程碑 1 发布
    GroupOffice 4.0.123 发布
    nagios总结与基本配置模板
    Zorin OS 6.1 发布,基于Ubuntu的Linux
    Ehcache 2.6.2 发布,Java 缓存框架
  • 原文地址:https://www.cnblogs.com/fengsantianya/p/5638668.html
Copyright © 2011-2022 走看看