Posted by webmaster Guido on March 18, 2008
In Reply to About Rich Edit Box posted by RussCAp12602 on
March 16, 2008
: How do I make data in a RichEdit Box line up in columns?
: I have tried using the $09 horizontal tab but it does not seem to do anything. Nor does using pad spaces work, since the font is variable width (I don't want to use the fixed width font).
: This is my next great hurdle, to be followed by trying to print everything nicely. Is it possible to use printer formatting controls, such as eject page?
: Is there some sample code that shows how to do all of this?
For aligning columns in Delphi's RichEdit component, you insert the TAB character (#9) between the columns. But it only works after some preparations (may look strange, I agree):
- firstly you have to tell how *many* TABs you'll use;
- next, you indicate their *positions*.
Here's an example:
RichEdit1.Paragraph.TabCount := 2; RichEdit.Paragraph.Tab := 100; RichEdit.Paragraph.Tab := 200; RichEdit.SelText := 'Column 1' + #9 + 'Column 2' + #9 + 'Column 3';
If you want to type text into the RichEdit, you can also add TABs by pressing the TAB key of the keyboard. But for this to have effect, at design time you should set the property WantTabs to True at design time.
The standard Delphi TRichEdit component contains built-in printing features for sending formatted text to the printer, but this is quite complicated. BTW, that's why Delphi programmers relay heavily on ready-to-use "report generators" or add-on printing components...
I'll post some examples in my next message, just gimme some time for testing the code -- at DelphiLand we never publish untested source code :)