Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove top bar on child form

Tags:

c#

Making an MDI form, i wish to remove the top bar on all child forms. Working on Visual studio and c#. Any idea how? Im clueless.

enter image description here

Here the properies of the child form:

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Normal
Me.MinimizeBox = False
Me.MaximizeBox = False
Me.ControlBox = False
Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.Dock = DockStyle.Fill
like image 306
Amine Fellous Avatar asked Oct 28 '25 09:10

Amine Fellous


1 Answers

Option 1: *

As mentioned in this answer, you can add a MenuStrip control to your MDI parent form, set its Visible property to false, and you should be good to go. The MDI child forms won't have a title bar displayed as long as they are maximized.


Option 2: *

  1. Set the MdiParent Property of the child form.
  2. Set the FormBorderStyle property of the child form to FormBorderStyle.None.
  3. Set the Dock property of the child form to DockStyle.Fill. Note: This must come after setting the MdiParent or else it won't work.
  4. That's it, you don't need to change any other properties (WindowState, ControlBox, etc.). Just maintain the order of the steps above.

Here's an example:

private void OpenAndDockMdiChild()
{
    Form2 childForm = new Form2();
    childForm.MdiParent = this;              // This must come **before** setting 
                                             // the `Dock` property.
    childForm.FormBorderStyle = FormBorderStyle.None;
    childForm.Dock = DockStyle.Fill;
    childForm.Show();
}

private void Form1_Load(object sender, EventArgs e)
{
    OpenAndDockMdiChild();
}

Result:

enter image description here Hope that helps.


* Tested with .NET 4.5.2 on both Windows 7 and Windows 10.

like image 66
41686d6564 stands w. Palestine Avatar answered Oct 31 '25 11:10

41686d6564 stands w. Palestine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!