Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multicolor Multiline TMemo

Tags:

delphi

Is it possible to configure Multicolor Multiline TMemo in Delphi XE2?.
When I am writing codes like :

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  FirstVariable, SecondVariable, ThirdVariable :BOOL;
begin
  if FirstVariable then
    begin
      Memo1.Font.Color := clGreen;
      Memo1.Lines.Add('FirstVariable = True');
    end
  else if SecondVariable then
    begin
      Memo1.Font.Color := clBlue;
      Memo1.Lines.Add('SecondVariable = True');
    end
  else
    begin
      Memo1.Font.Color := clRed;
      Memo1.Lines.Add('ThirdVariable = True');
    end;
end;

font color for all the previously existing lines are getting changed according to condition of the variables.

like image 290
user2325284 Avatar asked Apr 26 '13 20:04

user2325284


1 Answers

No, it is not possible. But you can use a RICHEDIT control instead, e.g., the TRichEdit wrapper.

RichEdit1.SelAttributes.Color := clGreen;
RichEdit1.Lines.Add('First line.');

RichEdit1.SelAttributes.Color := clBlue;
RichEdit1.Lines.Add('Second line.');

RichEdit1.SelAttributes.Color := clRed;
RichEdit1.Lines.Add('Third line.');
like image 183
Andreas Rejbrand Avatar answered Nov 03 '22 07:11

Andreas Rejbrand