How to set label text bold in delphi Xe8
Solution 1
Set label.StyledSettings.Style
false, then it will follow the Fontstyle
settings.
Here a sample code to toggle StyledSettings.Style
with in code (although I don't remember that I've ever played back and forth with these. For me it's more a one time setup at start).
procedure TForm6.Button9Click(Sender: TObject);
begin
if TStyledSetting.Style in Label3.StyledSettings then
Label3.StyledSettings := Label3.StyledSettings - [TStyledSetting.Style]
else
Label3.StyledSettings := Label3.StyledSettings + [TStyledSetting.Style]
end;
And to toggle the TextSettings.Font.Style
procedure TForm6.Button8Click(Sender: TObject);
begin
if TFontStyle.fsBold in Label3.TextSettings.Font.Style then
Label3.TextSettings.Font.Style := Label3.TextSettings.Font.Style - [TFontStyle.fsBold]
else
Label3.TextSettings.Font.Style := Label3.TextSettings.Font.Style + [TFontStyle.fsBold];
end;
Solution 2
Try this:
Label1.Font.Style := [fsBold];
I used delphi 10.4.
Related videos on Youtube
Remi
I'm a software engineering working as a junior software developer at Nocore in the Netherlands. I mostly create mobile apps with firemonkey multi device projects. Programming languages: Java SE, EE & Android Delphi C# Objective C ASP.NET Databases Oracle PL/SQL Microsoft Access SQLite MySQL
Updated on June 04, 2022Comments
-
Remi almost 2 years
How can you set a TLabel to Bold and back to normal runtime in Delphi XE8 firemonkey multi device project?
I've tried this but it doesn't work:
label.TextSettings.Font.Style := [TFontStyle.fsBold];
Also tried:
label.Font.Style := [TFontStyle.fsBold];
-
Remi almost 9 yearsThis isn't possible. Can only change label.styledsettings and not styledsettings.style
-
Tom Brunberg almost 9 yearsI can't check with XE8 right now. Do you mean that the Object Inspector doesn't show you the
StyledSettings
in XE8? -
Remi almost 9 yearsOw yes it shows in object inspector but i wanted to do it runtime. But thanks that works only how i do change the text to normal again after changing it to bold?
-
Jerry Dodge almost 9 yearsWhat you can do in design-time can also be done in run-time. Changing it back works the same way.