Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display simple markup in a Label in Delphi

Tags:

delphi

I am currently displaying some text in a TLabel. I would now like to emphasise certain words within the text by displaying them in bold or perhaps italic. What is the recommended way to do this in Delphi? Is there a TLabel-like component that can display simple HTML or markup? I am imagining some code like this:

label.text:='This information is <b>important</b>';

I am using Delphi 2010

like image 295
awmross Avatar asked Dec 14 '10 04:12

awmross


1 Answers

If you are already using a newer version of Delphi (at least the XE2 version), you can take a look at my TDzHTMLText component at: https://github.com/digao-dalpiaz/DzHTMLText

This component is a label with some HTML tags support, allowing you to format the text with Bold, Italic, Underline, Font Color, Font Size, Background Color, Tab Alignment, Text Alignment (left, center, right).

Check a print example:

DzHTMLText component example at design-time

The list below describes all possible tags to format label text:

<A[:abc]></A> - Link
<B></B> - Bold
<I></I> - Italic
<U></U> - Underline
<S></S> - Strike out
<FN:abc></FN> - Font Name
<FS:123></FS> - Font Size
<FC:clColor|$999999></FC> - Font Color
<BC:clColor|$999999></BC> - Background Color
<BR> - Line Break
<L></L> - Align Left
<C></C> - Align Center
<R></R> - Aligh Right
<T:123></T> - Tab
<TF:123></TF> - Tab with aligned break
like image 196
Digão Dalpiaz Avatar answered Sep 19 '22 12:09

Digão Dalpiaz