I've created a form which contains several controls. The main control is a tabControl, which contains several other controls. When I resize the main form, the tabs resize with no problems. But the controls in the tab are not resizing properly.
The attached screen shot, padefaultsize shows the form in it's normal state. When I resize, I expand the tab and the controls in the tab. The rest do not resize.
The screen shot paresized shows the form after I resize it. My graph (zgPeriodic) and panel (pnlPeriodic) drift outside of the tabs. I have the graph anchored at the bottom left, and the panel at the top right.
My code is as follows...
Code:
public void Form1_Resize(object sender, System.EventArgs e)
{
Control control = (Control) sender;
// resize tabPages
int tabh = (int)Math.Round((decimal)(control.Size.Height - 120));
int tabw = (int)Math.Round((decimal)(control.Size.Width - 200));
tabPages.Size = new Size(tabw, tabh);
// resize periodic tab
int periodicheight = (int)Math.Round((decimal)tabh / 2) - 2;
int zgperiodicheight = tabh - periodicheight - 45;
int gridwidth = (int)Math.Round((decimal).5775 * tabw);
int graphwidth = tabw - 12;
int pnlwidth = tabw - gridwidth - 19;
gridPeriodic.Size = new Size(gridwidth, periodicheight);
pnlPeriodic.Size = new Size(pnlwidth, periodicheight);
zgPeriodic.Size = new Size(graphwidth, zgperiodicheight);
}
Try not to manually resize the controls (just comment it all out - you can always uncomment later). Each control has the Anchor property that tells it how to maintain the distance between each of its edges and the edges of its parent control - try playing with that. You can even test how it behaves in the designer.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.