Tried setting Dock and anchor property
I can able to set position but,When I tried it on bigger screen like 1920*1080 ,size of those controls are not in proportion as per screen size. I want to change font of controls as screen width and height get change
waiting for help
thanks
seema bhoirPosted Mar 14, 2014, 1:34 AM
Thanks
but I think you r not changing font size
ok let me know what I want. I want to display form1 on multiple screens at a time
if I click on button screen 1 it should get display on screen 1 if i click screen2 then it should get display on screen 2
and screen size will change depend on customer . it might be like large tv screen
I am able to set a location of controls for all screen size the problem is as screen size change from small to large I want to increase font of controls to occupy blank space of screen
I have attached code if u want to see what I did
thank u
Brijendra GautamPosted Mar 13, 2014, 11:44 PM
Try this code
float previous_Width;
float previous_Height;
public Form2()
{
InitializeComponent();
panel1.BackColor = Color.Transparent;
panel2.BackColor = Color.Transparent;
previous_Width = this.Width;
previous_Height = this.Height;
}
private void Form2_Resize(object sender, EventArgs e)
{
float xRatio = (float)this.Width / (float)previous_Width;
float yRatio = (float)this.Height / (float)previous_Height;
SetFontSize(this,xRatio, yRatio);
previous_Width = this.Width;
previous_Height = this.Height;
}
private void SetFontSize(Control c, float xRatio, float yRatio)
{
foreach (Control cc in c.Controls)
{
if (cc is TextBox || cc is Label)
{
float size = cc.Font.Size;
Font fontFamily = cc.Font;
cc.Font = new Font(fontFamily.FontFamily, size * yRatio, fontFamily.Style);
cc.Location = new Point((int)(cc.Location.X * xRatio), (int)(cc.Location.Y * yRatio));
cc.Size = new Size((int)(cc.Size.Width * xRatio), (int)(cc.Size.Height * yRatio));
}
SetFontSize(cc, xRatio, yRatio);
}
}
Here I've resized the font-size and adjusted location of control when the Window is Resized.