RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomRichEdit.SelAttributes Property

Describes the rich text characteristics of the selected text in the rich edit control.

Pascal
property SelAttributes: TTextAttributes;
C++
__property TTextAttributes SelAttributes;

Use SelAttributes to discover or set the font characteristics of the currently selected text. SelAttributes specifies characteristics such as font face, color, size, style, and pitch. To change a single attribute of the currently selected text, read SelAttributes, and set one of its properties. To change all of the attributes of the currently selected text, set SelAttributes to a TTextAttributes object that represents the desired configuration of attributes. If no text is selected, SelAttributes represents the attributes of the cursor position. 

When inserting new text, the font characteristics of the new text will match SelAttributes.

Note: SelAttributes is available only at runtime.
 

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!