delphirichedit

How to left/right align lines in rich edit (Delphi)?


Is there a way I can align the line left or right in the TRichEdit component?

Clarification

I wish to align only a portion of the text, not all of it.


Solution

  • As Sertac mentioned in a comment, you use the TRichEdit.Paragraph.Alignment.

    RichEdit1.Paragraph.Alignment := taLeftJustify;
    RichEdit1.Lines.Add('This line is left justified.');
    RichEdit1.Paragraph.Alignment := taCenterJustify;
    RichEdit1.Lines.Add('This line is centered.');
    RichEdit1.Paragraph.Alignment := taRightJustify;
    RichEdit1.Lines.Add('This line is right justified');