DELPHI: RichEdit

The RichEdit is a text component used for input as well as output. The RichEdit can be found under Win32 on the component palette.

To add a line to a RichEdit the following line of coding can be used:

RichEdit1.Lines.Add('Name' + #9 + 'Surname')

Take note of the #9 that refers to a tab.

Other properties can be set as follows:

RichEdit1.Paragraph.Numbering := nsBullet; Adding bullets
RichEdit1.Paragraph.Numbering := nsNone; Remove bullets
RichEdit1.Paragraph.Alignment := taLeftJustify; Left aligned
RichEdit1.Paragraph.Alignment := taRightJustify; Right aligned
RichEdit1.Paragraph.Alignment := taCenter; Center aligned
RichEdit1.Paragraph.FirstIndent := 10; First indentation in pixels from the left (here 10 for example)

A RichEdit can be cleared by using RichEdit1.Clear; for example.

Tabs can also be used to list items exactly underneath each other. For this purpose the amount of tabs must be set and then the width be specified. For example:

RichEdit1.Paragraph.TabCount := 2;
RichEdit1.Paragraph.Tab[0] := 100;
RichEdit1.Paragraph.Tab[1] := 200;
RichEdit1.Lines.Add('Column A' + #9 + 'Column B' + #9 +'Column C')

Text written in a RichEdit can also be save directly into an RTF (Rich Text Format) file using the SaveToFile procedure. Files can also be opened using the LoadFromFile procedure. For example:



Return to Delphi resources index

Return to Home Page

JAK Olivier (2008)