Thema: Delphi richedit formatieren

Einzelnen Beitrag anzeigen

S.pas.s

Registriert seit: 16. Aug 2011
5 Beiträge
 
Delphi XE Professional
 
#11

AW: richedit formatieren

  Alt 16. Aug 2011, 13:38
Ich fands interessant und solange es Google findet, ist es für andere auch wertvoll.

Ich habs ausprobiert und fand, nachdem ich mich gefragt hatte, wozu das

"RichEdit1.ClearSelection;"

eigentlich da ist, dass es gar nicht nötig ist. Der Code geht genauso:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  RichEdit1.SelAttributes.Color := clRed;
  RichEdit1.SelText := 'Text rot ';

  RichEdit1.SelAttributes.Color := clBlue;
  RichEdit1.SelText := 'Text blau ';

  RichEdit1.SelAttributes.Color := clGreen;
  RichEdit1.SelText := 'Text schwarz';

  RichEdit1.Lines.Append('');

  RichEdit1.SelAttributes.Color := clBlack;
  RichEdit1.SelAttributes.Style := [fsBold];
  RichEdit1.SelText := 'Text FETT';

  RichEdit1.SelAttributes.Color := clMaroon;
  RichEdit1.SelAttributes.Style := [fsUnderline];
  RichEdit1.SelText := ' ENDE';

  RichEdit1.Lines.Append('');
end;
  Mit Zitat antworten Zitat