WinForms bold label displays correctly in Visual Studio Designer but gets squished when running the application

huangapple go评论73阅读模式
英文:

WinForms bold label displays correctly in Visual Studio Designer but gets squished when running the application

问题

如下图所示,正常的WinForms标签在设计器和运行应用程序中都正常工作,但加粗的标签在运行应用程序的某一点之后会变形。我除了将第二个标签的字体样式设置为粗体之外,没有更改标签的默认属性。我做错了什么?
WinForms bold label displays correctly in Visual Studio Designer but gets squished when running the application

英文:

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?

WinForms bold label displays correctly in Visual Studio Designer but gets squished when running the application

答案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.

huangapple
  • 本文由 发表于 2023年5月29日 19:30:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76356954.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定