1

I am adding lines of text to a TMemo using : Memo1.Lines.Add(Text), which causes Memo1 to scroll to the bottom.

Is there any way to either stop it scrolling as I add lines, or force it to go back to the top when I finished?

I want a simple solution...

Thanks...

1

2 Answers 2

7

Set the Memo's SelStart property to 0 and then send an EM_SCROLLCARET message to the Memo.

Memo1.Lines.BeginUpdate; try Memo1.Lines.Add(...); ... Memo1.SelStart := 0; Memo1.SelLength := 0; Memo1.Perform(EM_SCROLLCARET, 0, 0); finally Memo1.Lines.EndUpdate; end; 
Sign up to request clarification or add additional context in comments.

Comments

5

You can use begin/end update for lines collection:

memo.Lines.BeginUpdate; try memo.Lines.Add('test'); finally memo.Lines.EndUpdate; end; 

2 Comments

All this does is prevents the Memo from redrawing on each add. It does not affect scrolling.
@ThomasJomphe: if it works, you should accept an answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.