开发者

How to autoscroll to the end of RichEdit?

开发者 https://www.devze.com 2023-03-13 21:22 出处:网络
I never needed to use the TRichEdit before, always used TMemo. I\'d like RichEdit autoscrolling to the end when I add text like TMemo. See how it looks after you add some data:

I never needed to use the TRichEdit before, always used TMemo.

I'd like RichEdit autoscrolling to the end when I add text like TMemo. See how it looks after you add some data:

How to autoscroll to the end of RichEdit?

As you can开发者_开发知识库 see, the scroll bar remains at the top, but I'd like it stayed at the bottom as I added text.

I've 'googled' for solutions but I couldn't find a good and reliable one.


Try this code

RichEdit1.SetFocus;
RichEdit1.SelStart := RichEdit1.GetTextLen;
RichEdit1.Perform(EM_SCROLLCARET, 0, 0);


Here is much easier and fast solution:

In OnChange event handler just:

SendMessage(RichEdit1.handle, WM_VSCROLL, SB_BOTTOM, 0);

Original answer from: https://www.experts-exchange.com/questions/21002277/Richedit-autoscrolling.html


In short, you need to place the cursor at the end, or send code to scroll down.

Have you tried

Richedit1.SelStart :=RichEdit1.GetTextLength();
SendMessage(RichEdit1.handle, EM_SCROLLCARET,0,0);
0

精彩评论

暂无评论...
验证码 换一张
取 消