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));
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With