RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTextAttributes.Color Property

Indicates the foreground color of the text.

Pascal
property Color: TColor;
C++
__property TColor Color;

Use color to indicate the color of the actual characters.

Note: The background color is a property of the rich edit control that uses the TTextAttributes object, and should be set by the Color property of the rich edit control.
 

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!