开发者

WinForms Control position in Simplified Chinese

开发者 https://www.devze.com 2023-01-06 19:18 出处:网络
We have a WinForms application that includes controls such as picture boxes that are positioned on a form. The base application is in English.

We have a WinForms application that includes controls such as picture boxes that are positioned on a form. The base application is in English.

We've translated this application to a number of different languages (French, Spanish, Danish, Greek, etc.) and most recently to Simplified Chinese. The translated application works perfectly on our operation systems (English).

One of our customers installed the application on their operation system, Windows XP in Simplified Chinese. The layout of our application is broken. Simply put, the elements are pushed to the bottom right by a factor that is proportional to the distance between the element and the top left corner. For example, an element at the top right corner in design view is pushed off screen to the right whereas the items at the bottom of the page are pushed downwards and to the right.

The application supports switching langu开发者_运维知识库ages while in use. When the locale is en-US, there are no layout issues. When switching to Simplified Chinese, the issue appears, but only on the Simplified Chinese operating system. The screen resolution and DPI are the same.

Do you have any ideas? I'm sure it must be a simple configuration setting somewhere, but I have been unable to solve this issue.


The size of the system base font matters as well. Which is indeed something you can change on XP. This will invoke the form's auto-scaling logic, designed to ensure that the controls grow larger to fit the larger font size.

This is by design, controlled by the form's AutoScaleMode property. Don't change it, rescaling is important. Just make sure the form layout still looks good, use properties like Anchor and Dock, controls like TableLayoutPanel, FlowLayoutPanel. Or the Resize event for tricky ones.

Paste this into your form to test this logic without having to change system settings:

    protected override void OnLoad(EventArgs e) {
        this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * 125 / 96);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号