Parent - Child windows

Hello all, i think this is pretty easy question for you, but i have no idea how i can do it. I want to have a windows application in which the main window will be always open and the "child" window will open inside the main (all the children windows will open inside the main). Something like a form with some menu items and when you click on them they open other forms in the main window's area.

How can i set that the main window will be the "main", how about the settings i have to set to tell the children windows that are accually "child" and how to set the area (in the main window) in which the children windows will open

Thanks a lot!



Answer this question

Parent - Child windows

  • Cristian Salvan

    It is working fine! Thanks
  • RHEandDOTNET

    It seems that you are looking for what is genrally called MDI - Multiple Document Interface. The Form class has a property called IsMDIContainer. Set that property to true and then in your menu item click event methods put code like this to display a form called YourForm:

    void menuItem1_Click(object sender, EventArgs e)

    {

    YourForm form = new YourForm();

    form.MdiParent = this;

    // you can set the size if you want

    form.Size = new Size(100, 100);

    // you can set the position if you want

    form.StartPosition = FormStartPosition.Manual;

    form.Location = new Point(100, 100);

    // show the form

    form.Show();

    }


  • Vargess

    Forgot to mention that i am using VS2003
  • tencha

    Thank you, i will try this :)
  • Parent - Child windows