Sizing/positioning child forms within a parent form...
-
I've been playing around with the dynamic sizing, positioning, and MDI settings, but still can't achieve my goal and I'm sure someone else out there has done this... Here's my scenario: I have a frmMainContainer that acts as the primary controller for my application. It consists of a header 200px tall and 100% of the width of the form (used for control & branding) and the remainder of the area below is where my other forms will appear (I'll call it MultiUseArea for this conversation). I have a few other forms (frmChild1, frmChild2, frmChild3)... these will be loaded from the frmMainContainer form... they also will not have the min/max/close/titlebar/border features of a typical form. Now, what I want to do is click basically click a button in frmMainContainer that will load one of the child forms into the MultiUseArea... here's the trick... I want to size the child form to take up 100% of the MultiUseArea. Here's what I'm struggling with: when I load the application frmMainContainer, there are no scrollbars. When I load one of the child forms, scroll bars pop up in frmMainContainer although it looks like if the scroll bars weren't present, it would fit perfectly. I've tried dynamically sizing the children using the ClientRectangle property of the frmMainContainer, I've tried disabling the AutoScroll, and making the child forms MDI children of the frmMainContainer among other things... I just can't figure it out. Any ideas? ---- Just in case I'm confusing anyone in my description... I'm thinking something like Quicken interface or the one shown here: http://www.bcentral.com/image/ss\_sbm1\_640.gif In my desired solution, the "invoice entry" form would not have the title bar or control boxes (min/max/close). Andrew Connell IM on MSN andrew@aconnell.com
-
I've been playing around with the dynamic sizing, positioning, and MDI settings, but still can't achieve my goal and I'm sure someone else out there has done this... Here's my scenario: I have a frmMainContainer that acts as the primary controller for my application. It consists of a header 200px tall and 100% of the width of the form (used for control & branding) and the remainder of the area below is where my other forms will appear (I'll call it MultiUseArea for this conversation). I have a few other forms (frmChild1, frmChild2, frmChild3)... these will be loaded from the frmMainContainer form... they also will not have the min/max/close/titlebar/border features of a typical form. Now, what I want to do is click basically click a button in frmMainContainer that will load one of the child forms into the MultiUseArea... here's the trick... I want to size the child form to take up 100% of the MultiUseArea. Here's what I'm struggling with: when I load the application frmMainContainer, there are no scrollbars. When I load one of the child forms, scroll bars pop up in frmMainContainer although it looks like if the scroll bars weren't present, it would fit perfectly. I've tried dynamically sizing the children using the ClientRectangle property of the frmMainContainer, I've tried disabling the AutoScroll, and making the child forms MDI children of the frmMainContainer among other things... I just can't figure it out. Any ideas? ---- Just in case I'm confusing anyone in my description... I'm thinking something like Quicken interface or the one shown here: http://www.bcentral.com/image/ss\_sbm1\_640.gif In my desired solution, the "invoice entry" form would not have the title bar or control boxes (min/max/close). Andrew Connell IM on MSN andrew@aconnell.com
Got it... Form2 frmForm2 = new Form2(); frmForm2.TopLevel = false; //<<< KEY CODE frmForm2.Parent = this; //<<< KEY CODE //position 200px down from top because top 200px are my app header System.Drawing.Point thePoint = new System.Drawing.Point(0, this.ClientRectangle.Y+200); frmForm2.Location = thePoint; //size child form to fill up 100% of the parent form EXCEPT for the upper [form width]x200 System.Drawing.Size theSize = new System.Drawing.Size(this.ClientRectangle.Width, this.ClientRectangle.Height-200); frmForm2.Size = theSize; frmForm2.Show(); Andrew Connell IM on MSN andrew@aconnell.com