0
Answer

Removing the comtrol box from child forms under a MDI form

Yoav

Yoav

20y
1.8k
1
It seems that even when the properties ControlBox, MinimizeBox and MaximizeBox are all set to FALSE, these boxes are still visible on the menu (for the child form). Close and Minimize don't work, but RestoreDown does work. Is it possible to eliminate these? using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Mdiforms { public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); // mainMenu1 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1}); // menuItem1 this.menuItem1.Index = 0; this.menuItem1.Text = "file"; // Form1 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(664, 266); this.IsMdiContainer = true; this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Form1"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.Form1_Load); } #endregion [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { Form2 child = new Form2(); child.MdiParent = this; child.Show(); } } public class Form2 : System.Windows.Forms.Form { private System.ComponentModel.Container components = null; public Form2() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { // Form2 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 266); this.ControlBox = false; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form2"; this.Text = "Form2"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.SizeChanged += new System.EventHandler(this.Form2_SizeChanged); } #endregion private void Form2_SizeChanged(object sender, System.EventArgs e) { this.WindowState = System.Windows.Forms.FormWindowState.Maximized; } } }