Winform Compatibility: Window is showing C# forms differently in different version of windows?

Hi All,

I was making one window program which was working correctly in my windows while development but when I try to install on someone's else laptop/desktop it gives weired result.
Most of the times font become so big that controls go out of screen.

I search alot and found 2 solution and want to share with you people also.
Best Solution:

1. Add below method in each form and this will adjust form.
protected override void OnSizeChanged(EventArgs e)
        {
            if (Handle != null) // Can be null because the event is invoked before the handle is created.
                BeginInvoke((MethodInvoker)(() => base.OnSizeChanged(e)));
        }

2. Add below code inside constructor which will work on load of form
           this.Location = new Point(0, 0);
           this.Size = Screen.PrimaryScreen.WorkingArea.Size;

both are working fine for me.
Please let me know if you have any better option or having issue in using above code.

Comment below.


Thanks
Abhi

Comments