Board index » delphi » RichEdit text colors

RichEdit text colors

Hi,

Could someone please help me with this. With the following code,
clicking button1 repeatedly adds blue text.  But if I click button2
(delete first line of text) then click button1 again the text is black
for the first click. Why is this going back to the default color
(black)? How can I be sure I'll get the text colors I want in a
richedit???

Thanks,

Dave
-------------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
begin
  Richedit1.SelAttributes.Color:=clBlue;
  Richedit1.Lines.Add('Some Text');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Richedit1.Lines.Delete(0);
end;
-------------------------------------------------------------------------

 

Re:RichEdit text colors


procedure TForm1.Button1Click(Sender: TObject);
begin
  Richedit1.Font.Color:=clBlue;
  Richedit1.Lines.Add('Some Text');
end;

aro...@aol.com

Re:RichEdit text colors


Quote
>Dave Smith wrote:

> procedure TForm1.Button1Click(Sender: TObject);
> begin

    Richedit1.SelStart := Richedit1.GetTextLen;  <<< add this line

Quote
>   Richedit1.SelAttributes.Color:=clBlue;
>   Richedit1.Lines.Add('Some Text');
> end;

________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Other Threads