I have a TWebLabel
which I want to underline using code.
During design-time, I can underline it through the properties:
But in run-time, it's not showing as underlined:
How can I solve this underline issue or do this via code instead of a design-time property?
Here's what I've tried and the errors I got:
WebLinkLabel1.Font.Style.fsUnderline := True;
[Error] illegal qualifier "." after "Style:set of TFontStyle"
WebLinkLabel1.Font.Style := fsUnderline;
[Error] Incompatible types: got "TFontStyle" expected "set of TFontStyle""
WebLinkLabel1.Font.Style := [fsUnderline];
No error, but the label isn't underlined. It's not working.
What is the correct way to underline a TWebLabel
in TMS WEB Core using Delphi?
The Style
property requires a set.
So I needed to do the following in order to underline the TWebLabel
using code:
WebLinkLabel1.Font.Style := [TFontStyle.fsUnderline];
But also note that if you have any CSS classes attached to the TWebLabel
via the ElementClassName
property, then the Font.Style
won't work at all. In this case, you need to underline the TWebLabel
using the following code:
WebLinkLabel1.ElementHandle.style.setProperty('text-decoration-line','underline');
Alternatively, if you're using Bootstrap, then you can just add the text-decoration-underline
class to the ElementClassName
property on the `TWebLabel. That will also underline it.