(page requirements)

Rich labels

TRichEdit is a multi-purpose control. For example, you can use it as a very sophisticated label control which can display multi color/font labels or even complex mathematical formulas.

First of all, we'll remove the border around the TRichEdit control (assuming it's named RichEdit1) and make it read only:

  RichEdit1.BorderStyle := bsNone;
  RichEdit1.ReadOnly    := True;

You can achieve basic formatting (such as bold, italic, etc.) of the text you want to display using TRichEdit's built in properties and methods, but if you want to display more complex text:

  • Go into any editor that supports RTF file format (Rich Text Format) such as Microsoft Word
  • Type and format your text/pictures any way you like
  • Save your work to a file using RTF file format (C:\TEST.RTF for example)
  • Now, to display what you just edited using our "rich label control:"

  RichEdit1.PlainText := False;
  RichEdit1.Lines.LoadFromFile( 
    'c:\test.rtf' );

NOTE: Since TRichEdit controls consume more memory than basic TLabel controls, you should replace TLabel controls with TRichEdit controls only when it's absolutely necessary.

 
 
Applicable Keywords : Components, Delphi, Delphi 2.x, Win32
 
 
 
Copyright © 2009 Chami.com. All Rights Reserved. | Advertise | Created in HTML Kit editor