Search code examples
c#formsmenustrip

Form in a form behind my menu strip


I created a Form with menu strip. When I click on a menu item I want to open a new From in my main From. It works but a part of the form is behind the menu like this :

enter image description here

my code :

WindowDossierProtection wdPr = new WindowDossierProtection();
wdPr.TopLevel = false;
this.Controls.Add(wdPr);
wdPr.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
wdPr.Dock = DockStyle.Fill;
wdPr.Show();

Can you help me ? thanks !!


Solution

  • Use BringToFront() to get your desired result:

    WindowDossierProtection wdPr = new WindowDossierProtection();
    wdPr.TopLevel = false;
    this.Controls.Add(wdPr);
    wdPr.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    wdPr.Dock = DockStyle.Fill;
    wdPr.BringToFront();
    wdPr.Show();