The correct way of handling variable DPI settings is not to detect them and adjust your controls’ sizes manually in a switch
statement (for starters, there are far more possibilities than those you show in your sample if
statement).
Instead, you should set the AutoScaleMode
property of your form to AutoScaleMode.Dpi
and let the framework take care of this for you.
Add the following code to your form’s constructor (or set this property at design time):
this.AutoScaleMode = AutoScaleMode.Dpi;
Although you might prefer to use AutoScaleMode.Font
. For more information on automatic scaling, see the MSDN documentation.