如何使用 Delphi TMS WEB Core 项目中的代码为 TWebLabel 添加下划线?

问题描述 投票:0回答:1

我有一个

TWebLabel
,我想使用代码在它下划线。

在设计时,我可以通过属性强调它:

但是我如何通过代码来做到这一点?


这是我尝试过的方法以及遇到的错误:

  • WebLinkLabel1.Font.Style.fsUnderline := True;

    [错误]非法限定符“.”在“样式:TFontStyle 集”之后

  • WebLinkLabel1.Font.Style := fsUnderline;

    [错误]不兼容的类型:得到“TFontStyle”预期“TFontStyle 集””


使用 Delphi 在 TMS WEB Core 中给

TWebLabel
下划线的正确方法是什么?

delphi underline tms tms-web-core
1个回答
0
投票

Style
属性需要一个集合。

所以我需要执行以下操作才能使用代码在

TWebLabel
下划线:

WebLinkLabel1.Font.Style := [TFontStyle.fsUnderline];

另请注意,如果您通过

TWebLabel
属性将任何 CSS 类附加到
ElementClassName
,则
Font.Style
将根本不起作用。在这种情况下,您需要使用以下代码在
TWebLabel
下划线:

WebLinkLabel1.ElementHandle.style.setProperty('text-decoration-line','underline');
© www.soinside.com 2019 - 2024. All rights reserved.