Display simple markup in a Label in Delphi

前端 未结 5 1354
温柔的废话
温柔的废话 2021-02-13 21:22

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

5条回答
  •  一生所求
    2021-02-13 21:40

    Some ideas:

    1. Have a look at TLinkLabel in ExtCtrls. It lets you add links.. it paints the linked part underlined. Maybe you can steal the code and add support for other tags like ?

    2. You can use a TRichEdit component.. It's not HTML as you describe, but it should do the trick of formatting your text.

    3. Use TjanMarkupLabel from this page. "TjanMarkupLabel is a TGraphicControl descendant that renders its Text property in HTML style. Supported tags: Bold, Italic, Underline, Font (face, size and color) and Break."

提交回复
热议问题