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