英文:
WinForms bold label displays correctly in Visual Studio Designer but gets squished when running the application
问题
如下图所示,正常的WinForms标签在设计器和运行应用程序中都正常工作,但加粗的标签在运行应用程序的某一点之后会变形。我除了将第二个标签的字体样式设置为粗体之外,没有更改标签的默认属性。我做错了什么?
英文:
As illustrated in the screenshot below, a normal WinForms label works fine in both the Designer and the running application, but a bold label will get distorted after a certain point in the running app. I haven't changed any default properties on the labels except for setting the font style to bold for the second label. What am I doing wrong?
答案1
得分: 2
将 Application.SetCompatibleTextRenderingDefault(false);
添加到 Program.cs
中解决了问题。我以为自从 Visual Studio 2015 起这一行会自动添加,但我忘记检查了,我正在处理的项目早于 IDE 自动包含这行的功能。
英文:
The solution turned out to be to add Application.SetCompatibleTextRenderingDefault(false);
to Program.cs
. I though that it was added by default since Visual Studio 2015, but I forgot to check and the project I was working on predates the automatic inclusion of this line by the IDE.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论