Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. MDI form with contents?

MDI form with contents?

Scheduled Pinned Locked Moved C#
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    patr1c1a
    wrote on last edited by
    #1

    I know MDI's are supposed to be just containers and they can't have contents other than maybe a menustrip. But I'd like to have a main window with buttons, images and other stuff, and then smaller windows that open inside it. Is there any way to make this main form and MDI and get the MDI contents (buttons and everything else) sent to back every time a new form is opened? I tried placing all my main form contents in a panel and then call the panel.sendToBack() method when a new form is opened, but it sends it SO back that it ends up in the back of my screen, even behind the main form ;P I know an option is to show the forms as modal dialogs, but I'm supposed to let the user work with more than one window at a time. Any hints? Thanks :thumbsup:

    D K 2 Replies Last reply
    0
    • P patr1c1a

      I know MDI's are supposed to be just containers and they can't have contents other than maybe a menustrip. But I'd like to have a main window with buttons, images and other stuff, and then smaller windows that open inside it. Is there any way to make this main form and MDI and get the MDI contents (buttons and everything else) sent to back every time a new form is opened? I tried placing all my main form contents in a panel and then call the panel.sendToBack() method when a new form is opened, but it sends it SO back that it ends up in the back of my screen, even behind the main form ;P I know an option is to show the forms as modal dialogs, but I'm supposed to let the user work with more than one window at a time. Any hints? Thanks :thumbsup:

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Look in your parent form Control collection. You'll find a control of type MdiClient that hosts all of your child windows. You get at it and use it just like any other control from your code, even undock it and resize it. You just can't get at it with the designer. Docs on it are here[^].

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      P 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Look in your parent form Control collection. You'll find a control of type MdiClient that hosts all of your child windows. You get at it and use it just like any other control from your code, even undock it and resize it. You just can't get at it with the designer. Docs on it are here[^].

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        P Offline
        P Offline
        patr1c1a
        wrote on last edited by
        #3

        Thanks for the tip ;) Although I'm not sure about what to do with the MdiClient control once I find it in the collection. I need to make it stay back while the user works with the child forms. Right now, only the form stays back but the panel inside it stays on top, covering the child forms when they open.

        modified on Friday, January 21, 2011 2:21 PM

        D 1 Reply Last reply
        0
        • P patr1c1a

          Thanks for the tip ;) Although I'm not sure about what to do with the MdiClient control once I find it in the collection. I need to make it stay back while the user works with the child forms. Right now, only the form stays back but the panel inside it stays on top, covering the child forms when they open.

          modified on Friday, January 21, 2011 2:21 PM

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You cannot make the MdiClient appear on top of other controls on the parent form. It'll stay behind all other controls on the Mdi Parent form. But, as I said, you can get a reference to the control and undock it and move it over to the side to make room for you other form controls. Something like:

          foreach (Control c in this.Controls) {
          if (c is MdiClient) {
          MdiClient mdic = (MdiClient)c;
          mdic.Dock = DockStyle.None;
          mdic.Anchor = AnchorStyles.None;
          mdic.BackColor = Color.Blue;
          mdic.Location = new Point(40, 40);
          mdic.Size = new Size(400, 400);
          }
          }

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          1 Reply Last reply
          0
          • P patr1c1a

            I know MDI's are supposed to be just containers and they can't have contents other than maybe a menustrip. But I'd like to have a main window with buttons, images and other stuff, and then smaller windows that open inside it. Is there any way to make this main form and MDI and get the MDI contents (buttons and everything else) sent to back every time a new form is opened? I tried placing all my main form contents in a panel and then call the panel.sendToBack() method when a new form is opened, but it sends it SO back that it ends up in the back of my screen, even behind the main form ;P I know an option is to show the forms as modal dialogs, but I'm supposed to let the user work with more than one window at a time. Any hints? Thanks :thumbsup:

            K Offline
            K Offline
            KarlRhodes
            wrote on last edited by
            #5

            If you dock the panel to top, any child form that you open should open over the top or under it in the form container.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups