How to set label text bold in delphi Xe8

15,218

Solution 1

Set label.StyledSettings.Style false, then it will follow the Fontstyle settings.

enter image description here

Here a sample code to toggle StyledSettings.Stylewith 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.

Share:
15,218

Related videos on Youtube

Remi
Author by

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, 2022

Comments

  • Remi
    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
    Remi almost 9 years
    This isn't possible. Can only change label.styledsettings and not styledsettings.style
  • Tom Brunberg
    Tom Brunberg almost 9 years
    I can't check with XE8 right now. Do you mean that the Object Inspector doesn't show you the StyledSettings in XE8?
  • Remi
    Remi almost 9 years
    Ow 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
    Jerry Dodge almost 9 years
    What you can do in design-time can also be done in run-time. Changing it back works the same way.