0

i have one MDI called MDIMain and 2 form the first one is MAINMENU and the second one is profile, in my mainmenu form i have a button and if i click the button it shows the profile form but the problem is that when i click the mainmenu form anywhere the profile form go behind the mainmenu.

here is my code: this button is from Mainmenu form

private void Button5_Click(object sender, EventArgs e)
{
    profile frm = new profile();
    frm .MdiParent = this.ParentForm;
    frm .Show();
}

edited: this is the code form my mdi

private void MDIMAIN_Load(object sender, EventArgs e)
    {
        MAINMENU mn = new MAINMENU();
        mn.MdiParent = this;
        mn.Show();
    }
Denver
  • 147
  • 3
  • 17
  • You aren't showing enough code, but I'm guessing you need this: `frm.MdiParent = this.MdiParent;` – LarsTech Jan 26 '17 at 17:28
  • @LarsTech it's the same it goes behind the first child. – Denver Jan 26 '17 at 17:31
  • Post the code that duplicates that for us. What you have posted so far doesn't do that. – LarsTech Jan 26 '17 at 17:32
  • what do you mean by duplicate? thats the only code i have so far in my first child. – Denver Jan 26 '17 at 17:33
  • on the mainmenu, a button click event, i have updated my question. – Denver Jan 26 '17 at 17:35
  • @LarsTech see the update of my question. – Denver Jan 26 '17 at 17:37
  • `the problem is that when i click the mainmenu form anywhere the profile form go behind the mainmenu.` This is actually how it's supposed to work. – LarsTech Jan 26 '17 at 17:43
  • how am i going to prevent it? i dont want to use a showdialog if possible. i want the profile form stays on top even if i click the mainmenu form – Denver Jan 26 '17 at 17:44
  • 1
    It's not clear what you want to have. Is the MainMenu supposed to be permanently docked? If so, don't set the MDI Parent. Make it TopLevel = false, Dock = Top, Border = None and add it as a control: `this.Controls.Add(mn);` – LarsTech Jan 26 '17 at 17:46
  • i will try the other way you show me thank you. – Denver Jan 26 '17 at 17:49

0 Answers0