Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current screen resolution in c#

How can I get the current screen resolution of the screen where my form is?

I've already tried with primaryScreen but it does not work all times.

this.Size = new Size(Math.Min(width + 19, Screen.PrimaryScreen.WorkingArea.Width), Math.Min(height + dgvActualizar.ColumnHeadersHeight + 40, Screen.PrimaryScreen.WorkingArea.Height));
like image 241
Israel Morales Avatar asked Dec 05 '25 13:12

Israel Morales


1 Answers

You are probably looking for the FromControl method:

Screen screenFormIsOn = Screen.FromControl(this);
var width = screenFormIsOn.WorkingArea.Width;
var height = screenFormIsOn.WorkingArea.Height;

Screen.FromControl should return the screen in which your form is loaded on.

like image 187
Icemanind Avatar answered Dec 07 '25 04:12

Icemanind



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!