找到你要的答案

Q:How to set label text bold in delphi Xe8

Q:如何设置标签文本在Delphi xe8大胆

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];

你怎么能把一个TLabel大胆和Delphi xe8 FireMonkey多设备项目恢复正常运行?

我试过了,但不起作用:

label.TextSettings.Font.Style := [TFontStyle.fsBold];

也试过:

label.Font.Style := [TFontStyle.fsBold];
answer1: 回答1:

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

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;

集label.styledsettings.style假,那么它将遵循字体样式设置。

这里的示例代码切换styledsettings。风格的代码(虽然我不记得我曾经来回这些。对我来说,这是更多的一一次设置开始)。

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;

和切换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;
delphi  fonts  firemonkey  delphi-xe8  tlabel