RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTextAttributes.Style Property

Determines whether the font is normal, italic, underlined, bold, or strikeout.

Pascal
property Style: TFontStyles;
C++
__property TFontStyles Style;

The Style property is a set drawn from the following values:

Value 
Meaning 
fsBold  
The font is boldfaced.  
fsItalic  
The font is italicized.  
fsUnderline  
The font is underlined.  
fsStrikeOut  
The font is displayed with a horizontal line through it.  

Because the Style property is a set, it can contain multiple values. For example, a font could be both boldfaced and italicized.  

C++ Examples: 

 

/*
This example requires a TRichEdit and two TButtons. Leave
the default text, usually "RichEdit1", in the lines
property. The DefAttributes will apply to this text.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  RichEdit1->SelAttributes->Color = clRed;
  RichEdit1->SelAttributes->Height += 5;
  RichEdit1->Lines->Add("This line of text will be red. ");
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
  RichEdit1->DefAttributes->Color = clBlue;
  RichEdit1->DefAttributes->Style =
    RichEdit1->DefAttributes->Style << fsBold << fsItalic;
}

 

Delphi Examples: 

{
This example requires a TRichEdit and two TButtons. Leave
the default text, usually "RichEdit1", in the lines
property. The DefAttributes will apply to this text.
}
procedure TForm1.Button1Click(Sender: TObject);
begin
  with RichEdit1.SelAttributes do
  begin
    Color := clRed;
    Height := Height + 5;
  end;
  RichEdit1.Lines.Add('This line of text will be red.');
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
  RichEdit1.DefAttributes.Color := clBlue;
  RichEdit1.DefAttributes.Style := [fsBold, fsItalic];
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!