111,126
社区成员
发帖
与我相关
我的任务
分享
//写在父窗体(Form1)里面的代码(就这么一点)
this.IsMdiContainer = true;//指示窗体为多文档界面
Form2 f2 = new Form2();
f2.MdiParent = this;//指示父窗体
//f2.StartPosition = FormStartPosition.CenterParent;//可要可不要
f2.Show();
//百度、谷歌 一下 应该知道很多…
using System;
using System.Windows.Forms;
public class Form1 : Form
{
public Form1()
{
this.IsMdiContainer = true;
MenuStrip ms = new MenuStrip();
ToolStripMenuItem windowMenu = new ToolStripMenuItem("Window");
ToolStripMenuItem windowNewMenu = new ToolStripMenuItem("New", null, new EventHandler(windowNewMenu_Click));
windowMenu.DropDownItems.Add(windowNewMenu);
((ToolStripDropDownMenu)(windowMenu.DropDown)).ShowImageMargin = false;
((ToolStripDropDownMenu)(windowMenu.DropDown)).ShowCheckMargin = true;
ms.MdiWindowListItem = windowMenu;
ms.Items.Add(windowMenu);
ms.Dock = DockStyle.Top;
this.MainMenuStrip = ms;
this.Controls.Add(ms);
}
void windowNewMenu_Click(object sender, EventArgs e)
{
Form f = new Form();
f.MdiParent = this;
f.Text = "Form - " + this.MdiChildren.Length.ToString();
f.Show();
}
static void Main()
{
Application.Run(new Form1());
}
}