I'd like to know how I can have a child form load up with it's size covering the complete MDI Parent's MDI container space (the dark-gray thing)? Setting the child form's WindowState to Maximized is not an option as it'll maximize any other form too. Suggestions?
Asked
Active
Viewed 2.4k times
3
-
I'm sorry I don't have a solution to your problem, but I have to thank you for the aside about setting the WindowState. That solved a problem I was having. – Mark Meuer Apr 25 '11 at 20:44
3 Answers
5
I think this code should do it:
Form childForm = new Form();
f.Left = 0;
f.Top = 0;
f.Size = ParentForm.ClientRectangle.Size;

Chris Shain
- 50,833
- 6
- 93
- 125
-
It's not opening up properly in the sense that the width and height is way to big. Here is the code I have tried so far and its not adjusting: `private void LoadDashboard() { Cursor saveCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; Dashboard DisplayFormC = new Dashboard { MdiParent = this, Left = 0, Top = 0, Size = new Size(ClientRectangle.Size.Width - 200, ClientRectangle.Size.Height - 200) }; DisplayFormC.Show(); } finally { Cursor.Current = saveCursor; } }` – DoomerDGR8 Mar 01 '11 at 07:57
-
Try the code laid out here: http://stackoverflow.com/questions/603788/size-location-of-winforms-mdi-client-area – Chris Shain Mar 01 '11 at 22:47
1
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/a315cefe-fe7f-4e23-b3e0-6cf614501ac2/ check the link the issue is resolved by inheriting the size

Joel Swiss
- 11
- 2
1
I added a couple of lines to get it to fit inside the frame and it works well.
Form childForm = new Form();
childForm.Left = 0;
childForm.Top = 0;
Rectangle recNew = new Rectangle();
recNew = ParentForm.ClientRectangle;
recNew.Height -= 4;
recNew.Width -= 4;
childForm .Size = recNew.Size;
I hope that helps!

trevor
- 257
- 3
- 9