The aim is to only use one #9 between values to produce neat columns.
The problem is if you set your tab stops in such a way that the strings won't fit, Delphi will ignore them.
Tips and tricks:
First clear the RichEdit. If you clear the RichEdit after the setting of the tab stops you will lose the tab stop settings.
Code the heading for your columns - redOut.Lines.Add('Name'+#9+'Surname'+#9+'Mark');
Count the number of #9's that you used. There will be one less than the number of columns.
Add the TabCount code above the heading but after the .clear. TabCount will be equal to the number of #9's in the heading - redOut.Paragraph.TabCount := 2;
Delphi starts counting from 0 so tab stop 1 is tab number 0 - redOut.Paragraph.Tab[0] := 100;
I use the following as a guideline to work out what value I need to give each tab.
Strings - a value of 100 - 150
Numbers of single characters - a value of 50 - 100.
Remember that Delphi always measures from the left of the screen (see picture below). Therefore the first tab (tab[0]) will have the smallest value and the ones that follow will be larger than the one before it - redOut.Paragraph.Tab[0] := 100; redOut.Paragraph.Tab[1] := 200;
Columns still not aligned?
Ensure that your RichEdit is wide enough to display the values in columns.
If your columns look like the screenshot below on the right, you need to give the second tab stops a higher value.
Make sure that the tab stops are set after the .clear and before the headings of the columns.
Tab stops are measured from the left of the RichEdit. The fist Tab is at 50 and the second Tab is at 100.
RichEdit is not wide enough
Second tab stop needs to be set to a higher value
Tab stops code