Resize Windows Forms according to screen

//From https://social.msdn.microsoft.com/Forums/en-US/bfb15fd0-533a-47b8-af07-472310002f26/c-winforms-resizing-forms?forum=csharplanguage private void MainForm_Load( object sender, EventArgs e ) { float width_ratio = (Screen.PrimaryScreen.Bounds.Width / 1280); float heigh_ratio = (Screen.PrimaryScreen.Bounds.Height / 800f); SizeF scale = new SizeF(width_ratio, heigh_ratio); this.Scale(scale); foreach (Control control in this.Controls) { control.Font = new Font("Microsoft Sans Serif", control.Font.SizeInPoints * heigh_ratio * width_ratio); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.