1.首先,新建一个窗体,设置窗体的IsMdiContainer = true;
窗体的大小为700*600 长700 高600
2.在窗体的Load事件中添加如下代码
private void FormMain_Load(object sender, EventArgs e) { Form form = new Form(); form.FormBorderStyle = FormBorderStyle.FixedToolWindow; form.MdiParent = this; form.Dock = DockStyle.Left; form.Width = 200; form.Show(); Form form2 = new Form(); form2.FormBorderStyle = FormBorderStyle.FixedToolWindow; form2.MdiParent = this; form2.Dock = DockStyle.Bottom; form2.Height = 100; form2.Show(); LayoutMdi(MdiLayout.ArrangeIcons); }
最上层是一个菜单栏
下面是一个工具栏
最底层是一个状态栏
选中第一个子窗体
选中第二个子窗体
另外一种形式,多加了2个窗体
private void Form1_Load(object sender, EventArgs e) { try { //在窗体的底部 Form form2 = new Form(); form2.FormBorderStyle = FormBorderStyle.FixedToolWindow; form2.MdiParent = this; form2.Dock = DockStyle.Bottom; form2.Height = 100; form2.Text = @"窗体2"; form2.Show(); Splitter splitter=new Splitter(); splitter.Dock = DockStyle.Bottom; //在窗体的左侧 Form form = new Form(); form.FormBorderStyle = FormBorderStyle.FixedToolWindow; form.MdiParent = this; form.Dock = DockStyle.Left; form.Width = 200; form.Text = @"窗体1"; form.Show(); Form form3 = new Form(); form3.MdiParent = this; form3.Dock = DockStyle.Fill; form3.Text = @"窗体3"; form3.MaximizeBox = false; form3.Show(); Form form4 = new Form(); form4.MdiParent = this; form4.Dock = DockStyle.Fill; form4.Text = @"窗体4"; form4.MaximizeBox = false; form4.Show(); //LayoutMdi(MdiLayout.TileHorizontal); } catch (Exception ex) { MessageBox.Show(ex.Message); } }