Docking a DialogBox into main form
-
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 -
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 PaoloI 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
-
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 PaoloHi, 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
-
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 Paolo1. 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.
-
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
Thanks a lot, how do I get the Main form control in order to do dialog.parent = mainformcontrol ? Thanks
-
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.
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
-
Thanks a lot, how do I get the Main form control in order to do dialog.parent = mainformcontrol ? Thanks
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