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

  • 相关阅读:
    poj 1743 Musical Theme 后缀数组
    poj 1743 Musical Theme 后缀数组
    cf 432D Prefixes and Suffixes kmp
    cf 432D Prefixes and Suffixes kmp
    hdu Data Structure? 线段树
    关于position和anchorPoint之间的关系
    ios POST 信息
    CALayers的代码示例
    CALayers详解
    ios中得sqlite使用基础
  • 原文地址:https://www.cnblogs.com/fengsantianya/p/5638668.html
Copyright © 2011-2022 走看看