Change part of string (memo) color

Hi,

Is there any option or script to change color just a parte of string inside a memo ?

Ex.: my meno10 = 'Hello world'. I want to change the word "world" to blue (clBlue), just that word.

of course it's a meno with database field. Can i add some script or change something beforeprint ?

thx for all

Comments

  • edited October 3

    Hello @ geometry dash lite, you can select the memo in the designer. Set the property:

    MemoView.AllowHTMLTags := True;

    Next, you can use HTML inside your string. In your OnBeforePrint event or wherever you're preparing the memo content, you can write something like:

    procedure Memo10OnBeforePrint(Sender: TfrxComponent);

    var

     s: string;

    begin

     s := <YourDataSet>.FieldByName('YourField').AsString;

     // Let's say s = 'Hello world'

     s := StringReplace(s, 'world', '<font color="#0000FF">world</font>', []);

     Memo10.Text := s;

    end;

    This changes only the word "world" to blue (#0000FF). You can also use color names like <font color="clBlue">.

    Finally, you can enable interpretation of HTML tags. Make sure Memo10.AllowHTMLTags := True is set.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.