Mega Code Archive

 
Categories / Delphi / VCL
 

Display last line in a MemoRichEdit

Title: Display last line in a Memo/RichEdit Question: If you keep adding lines to a Memo/RichEdi you'll get to the point where you won't see the last added line here's how to deal with it Answer: You just have to send the EM_SCROLL message to the control Memo1.Lines.Add('one more line'); SendMessage(Memo1.Handle, EM_SCROLL, SB_LINEDOWN, 0); or for RichEdit with RichEdit1 do begin Lines.Add('another boring line'); Perform( EM_SCROLL, SB_LINEDOWN, 0); end; That's for the case you are adding lines, but how about if I load a file from disk? here's the answer Memo1.SelStart:=Memo1.GetTextLen; Memo1.SelLength:=0; that's it :-)