SA :)
Finally there's an efficient way to adjust your controls in the form and to keep their relative positions and sizes.
review this and this :D
this method is very easy with perfect performance ;)
let's see a sample code for this:
public partial class Form1 : Form
{
int oldHeight = 299, oldWidth = 436;
int newHeight, newWidth;
float verticalScale, horizontalScale;
public Form1()
{
InitializeComponent();
}
private void Form1_Resize(object sender, EventArgs e)
{
newHeight = this.Height;
newWidth = this.Width;
verticalScale = (float)newHeight / oldHeight;
horizontalScale = (float)newWidth / oldWidth;
foreach (Control c in this.Controls)
{
c.Height = (int)(c.Height * verticalScale);
c.Width = (int)(c.Width * horizontalScale);
c.Top = (int)(c.Top * verticalScale);
c.Left = (int)(c.Left * horizontalScale);
}
oldWidth = this.Width;
oldHeight = this.Height;
}
}
all you have to do is to copy the parameters in your form, and set the oldHeight and oldWidth by the current Height and Width of your form in design mode.
int oldHeight = 299, oldWidth = 436;
int newHeight, newWidth;
float verticalScale, horizontalScale;
and then copy the code in the Form1_Resize() in your form resize handler and enjoy the results ;)