Wednesday, March 2, 2011

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;
    '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.

Source :

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum