Hi @Mohammad Hasan Salmanian , Welcome to Microsoft Q&A,
The first three lines of your code are the key to your form's changes.
Font = new Font("IRANSans", 15, GraphicsUnit.Pixel);
This line of code creates a font named "IRANSans" with a size of 15 pixels and assigns it to the Font
of the form or control Attributes. This means that when the text content of a form or control is displayed, the "IRANSans" font will be used, and the size of the text will be 15 pixels.
AutoScaleDimensions = new SizeF(5, 5);
This line of code sets the auto-scaling dimensions. Typically, automatic scaling is used to ensure that forms and controls maintain a consistent appearance across different display resolutions. AutoScaleDimensions
is used to specify to what extent scaling is performed, here setting to (5, 5) means that 5 logical units (usually device-independent pixels) in both horizontal and vertical directions are equal to one physical unit (usually inches ).
AutoScaleMode = AutoScaleMode.Font;
This line of code sets the autoscaling mode. The AutoScaleMode
property specifies when and how to automatically scale a form or control. Here, it is set to AutoScaleMode.Font
, which means that the autoscaling will adjust based on the size of the font to ensure a consistent appearance across different font sizes.
If you delete the first line of font settings, you will find that the form does not change.
You'd better design in the target style so it won't change at runtime.
DPI may also be a direction for your research.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.