菜单条问题:为什么菜单条总是占用子窗口的区域????实在时没分了,先欠着大家的。
1:菜单条问题:为什么菜单条总是占用子窗口的区域?2:为了看到直接效果,此代码可直接编译:csc *.csc;然后运行
//CODE
class MdiChildFrame : System.Windows.Forms.Form
{
public MdiChildFrame() {
System.Windows.Forms.MenuStrip mainMenu = new System.Windows.Forms.MenuStrip();
System.Windows.Forms.ToolStripMenuItem[] subMenu = {new System.Windows.Forms.ToolStripMenuItem()};
System.Windows.Forms.ToolStripMenuItem[] openFileMenu = {new System.Windows.Forms.ToolStripMenuItem()};
mainMenu.Text = "子窗口_主菜单";
mainMenu.Items.AddRange(subMenu);
this.Controls.Add(mainMenu);
this.MainMenuStrip = mainMenu;
subMenu[0].Text = "子窗口_文件";
subMenu[0].DropDownItems.AddRange(openFileMenu);
mainMenu.AllowMerge = true;
openFileMenu[0].Text = "子窗口_打开";
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0,0,100,100);
e.Graphics.DrawRectangle(pen,rect);
}
};
class MdiMainFrame : System.Windows.Forms.Form
{
public MdiMainFrame() {
this.IsMdiContainer = true;
MdiChildFrame childFrame = new MdiChildFrame();
childFrame.MdiParent = this;
//
System.Windows.Forms.MenuStrip mainMenu = new System.Windows.Forms.MenuStrip();
System.Windows.Forms.ToolStripMenuItem[] subMenu = {new System.Windows.Forms.ToolStripMenuItem()};
System.Windows.Forms.ToolStripMenuItem[] openFileMenu = {new System.Windows.Forms.ToolStripMenuItem()};
mainMenu.AllowMerge = true;
mainMenu.Text = "主菜单";
mainMenu.Items.AddRange(subMenu);
this.Controls.Add(mainMenu);
this.MainMenuStrip = mainMenu;
subMenu[0].Text = "文件";
subMenu[0].DropDownItems.AddRange(openFileMenu);
openFileMenu[0].Text = "打开";
//
this.Show();
childFrame.Show() ;
}
public static void Main(string[] args)
{
System.Windows.Forms.Application.Run(new MdiMainFrame());
}
};
补充:.NET技术 , C#