I have a form that appears as a modal dialog. The form looks like this in the designer:
(width = 360, height = 215)
When it is shown in the application, it gets 10 pixels taller and wider than is defined, leaving a wide margin around the bottom and left edges:
(width = 370, height = 225)
The form is explicitly set to be 360x215 pixels in dimension, has a border style of FixedDialog
, inherits from System.Windows.Forms.Form
, and has no code in it to manipulate the dimensions (with the exception of the auto-generated designer file). If I change the border style to FixedSingle
or FixedToolWindow
it appears the correct size (but I want it styled as FixedDialog
).
Any idea what is causing this?
I've fixed this by removing the MinimumSize
setting on the form. It appears that if it is set to the same size (or near, but I haven't quite found the threshold yet) as the Size
property, the margins are introduced. As the form is not resizable, I don't need the MinimumSize
set so it can be removed.
I still don't understand why this is the case though.
Size
,MinimumSize
andMaximumSize
are all set to360, 215
. – BeneficentAutoscaleMode
property. What's it set at on the form (it can be one ofFont
,Dpi
,Inherit
orNone
)? Does it still happen when you setAutoscaleMode
toNone
? – UnswervingAutoScaleMode
is set toInherit
. – BeneficentAustoscale
None
- if so what's the result? – Unswerving