zoukankan      html  css  js  c++  java
  • 多文档窗口MDI

     1//-----------------------------------------------
     2父窗口代码
     3
     4//-----------------------------------------------
     5 public Main()
     6        {
     7            InitializeComponent();
     8            //启用Windows XP视觉样式
     9            Application.EnableVisualStyles();
    10
    11
    12            //创建子窗体实例
    13            WindowsApplication1.ListBoxSample child = new WindowsApplication1.ListBoxSample(this);
    14
    15            //显示子窗体
    16
    17            child.Show();
    18
    19
    20            
    21        }

    22
    23//-----------------------------------------------
    24子窗口代码
    25
    26//-----------------------------------------------
    27 public ListBoxSample(WindowsApplication1.Main parent)
    28        {
    29            InitializeComponent();
    30
    31            //指定父窗口对象
    32            this.MdiParent = parent;
    33
    34            GetListItems(checkedListBox1);
    35        }

    36
    37
    38//-----------------------------------------------
    39子窗口重载
    40
    41//-----------------------------------------------
    42
    43  private void listBoxSample1ToolStripMenuItem_Click(object sender, EventArgs e)
    44        {
    45            
    46Form fm=new ListBoxSample(this);
    47fm.Show();
    48
    49        }

    50
    51//-----------------------------------------------
    52父子窗口中的菜单设置
    53
    54//-----------------------------------------------
    55父窗口
    56&File的MergeAction属性=Replace
    57子窗口
    58&File的MergeAction=MatchOnly
    59工具栏的AllowMerge=false
    60
    61
    62
    63//-----------------------------------------------
    64MDI窗口选项设置
    65
    66//-----------------------------------------------
    67menuStrip1的属性MdiWindowListItem指向Windows菜单
    68
    69如果要在菜单上创建平铺和前后的效果,添加两个菜单项,然后使用如下代码:
    70
    71        private void 平铺ToolStripMenuItem_Click(object sender, EventArgs e)
    72        {
    73            LayoutMdi(MdiLayout.TileHorizontal);
    74        }

    75
    76        private void 前后ToolStripMenuItem_Click(object sender, EventArgs e)
    77        {
    78            LayoutMdi(MdiLayout.Cascade);
    79        }
  • 相关阅读:
    [CF864F]Cities Excursions
    [AGC012F]Prefix Median
    [TC-FindingFriends]Finding Friends
    [TC-HouseProtection]House Protection
    [CTSC2018]假面
    [CF877F]Ann and Books
    [CF509F]Progress Monitoring
    [CF735E/736C]Ostap and Tree
    CF611H New Year and Forgotten Tree
    CF538H Summer Dichotomy
  • 原文地址:https://www.cnblogs.com/tiasys/p/605249.html
Copyright © 2011-2022 走看看