RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TParaAttributes.Alignment Property

Specifies how text is aligned within a paragraph.

Pascal
property Alignment: TAlignment;
C++
__property TAlignment Alignment;

Use Alignment to specify the alignment of text within individual paragraphs. Unlike the Alignment property of a TCustomMemo, which applies to the entire body of text, the Alignment property of TParaAttributes applies only to the selected paragraphs. 

These are the possible values:

Value 
Meaning 
taLeftJustify  
Align text to the left side of the paragraph.  
taCenter  
Center text horizontally in the paragraph.  
taRightJustify  
Align text to the right side of the paragraph.  

 

C++ Examples: 

/*
To use this example, place a Toolbar and a RichEdit on the 
form. Right click the toolbar and select New Button three 
times.  Place the ToolButton1Click handling code in the on 
click event of the first TToolButton, then attach the same 
OnClick handler for each button.  Double click on the Image-
List to load the images.  Load in the order right, center
and left.  Name the Imagelist ToolbarImages.  Select the
Toolbar and set the Images property to ToolbarImages.  Then
select each ToolButton and set the ImageIndex property.
Selected lines on the RichEdit will be aligned when the tool
bar buttons are clicked.
*/
void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
  if (Sender == ToolButton1)
    RichEdit1->Paragraph->Alignment = taLeftJustify;
  else if (Sender == ToolButton2)
    RichEdit1->Paragraph->Alignment = taCenter;
  else if (Sender == ToolButton3)
    RichEdit1->Paragraph->Alignment = taRightJustify;
}

 

Delphi Examples: 

{
To use this example, place a Toolbar and a RichEdit on the 
form. Right click the toolbar and select New Button three 
times.  Place the ToolButton1Click handling code in the on 
click event of the first TToolButton, then attach the same 
OnClick handler for each button.  Double click on the Image-
List to load the images.  Load in the order right, center
and left.  Name the Imagelist ToolbarImages.  Select the
Toolbar and set the Images property to ToolbarImages.  Then
select each ToolButton and set the ImageIndex property. 
}
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
   if (Sender = ToolButton1) then
    RichEdit1.Paragraph.Alignment := taLeftJustify
  else if (Sender = Toolbutton2) then
    RichEdit1.Paragraph.Alignment := taCenter
  else if (Sender = Toolbutton3) then
    RichEdit1.Paragraph.Alignment := taRightJustify;

end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!