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. Windows Forms
  4. Docking a DialogBox into main form

Docking a DialogBox into main form

Scheduled Pinned Locked Moved Windows Forms
question
7 Posts 4 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
    Ponzano Paolo
    wrote on last edited by
    #1

    Hello, maybe it's a stupid question, I had a form that before was shown as DialogBox with DialogBox.ShowDialog();, now my boss want me to dock it on the right side of the main application, how can I do that? Thanks in advance Paolo

    P L D 3 Replies Last reply
    0
    • P Ponzano Paolo

      Hello, maybe it's a stupid question, I had a form that before was shown as DialogBox with DialogBox.ShowDialog();, now my boss want me to dock it on the right side of the main application, how can I do that? Thanks in advance Paolo

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      I think ShowDialog makes the form modal and as far as I know, you really can't dock a modal window.

      "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

      1 Reply Last reply
      0
      • P Ponzano Paolo

        Hello, maybe it's a stupid question, I had a form that before was shown as DialogBox with DialogBox.ShowDialog();, now my boss want me to dock it on the right side of the main application, how can I do that? Thanks in advance Paolo

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, I have not done this before, but AFAIK these are necessary steps: - set Form.TopLevel false - add the Form to its parent's Controls I expect ShowDialog() is forbidden (conflicts with TopLevel=false) and Show() is not necessary, since Form got demoted to a Control now. You would want to play around with Location, Dock and/or Anchor properties. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        P 1 Reply Last reply
        0
        • P Ponzano Paolo

          Hello, maybe it's a stupid question, I had a form that before was shown as DialogBox with DialogBox.ShowDialog();, now my boss want me to dock it on the right side of the main application, how can I do that? Thanks in advance Paolo

          D Offline
          D Offline
          darkelv
          wrote on last edited by
          #4

          1. Add a SplitContainer where the right panel is your "dock" of the dialogbox. 2. In your code, after instantiate the form, set TopLevel = false, then add the form to the right panel's Control. Call form.Show() after that. You may need to change the way your main form works. YMMV.

          P 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, I have not done this before, but AFAIK these are necessary steps: - set Form.TopLevel false - add the Form to its parent's Controls I expect ShowDialog() is forbidden (conflicts with TopLevel=false) and Show() is not necessary, since Form got demoted to a Control now. You would want to play around with Location, Dock and/or Anchor properties. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


            P Offline
            P Offline
            Ponzano Paolo
            wrote on last edited by
            #5

            Thanks a lot, how do I get the Main form control in order to do dialog.parent = mainformcontrol ? Thanks

            L 1 Reply Last reply
            0
            • D darkelv

              1. Add a SplitContainer where the right panel is your "dock" of the dialogbox. 2. In your code, after instantiate the form, set TopLevel = false, then add the form to the right panel's Control. Call form.Show() after that. You may need to change the way your main form works. YMMV.

              P Offline
              P Offline
              Ponzano Paolo
              wrote on last edited by
              #6

              thanks for your reply, and what should I do about the left one? size it to 0? as I've asked before how do I get the parent control? have I to pass it as parameter to constructor of the dialogbox? Ho do I get it from main form? Thanks Bests Paolo Ponzano

              1 Reply Last reply
              0
              • P Ponzano Paolo

                Thanks a lot, how do I get the Main form control in order to do dialog.parent = mainformcontrol ? Thanks

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                There are several ways, I think I would go for this one: have the main form perform all, i.e. create the dialog, reset toplevel, add to its own Controls collection, take care of Location. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


                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