Link to home
Start Free TrialLog in
Avatar of zebada
zebada

asked on

How to get TRichedit to scroll

How do I make a richedit control automatically scroll as more lines are added to it?
Avatar of CrazyOne
CrazyOne
Flag of United States of America image

An easy way to do it would be like this

TRichedit.SelStart := Length(TRichedit.Text);


The Crazy One
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Epsylon
Epsylon

Or

RichEdit1.Perform(EM_Scroll, SB_PAGEDOWN, 0);
RichEdit1.Perform(EM_Scroll, SB_PAGEUP, 0);
RichEdit1.Perform(EM_Scroll, SB_LINEDOWN, 0);
RichEdit1.Perform(EM_Scroll, SB_LINEUP, 0);
Avatar of zebada

ASKER

CrazyOne,
TRichedit.SelStart := Length(TRichedit.Text);
Doesn't seem to work when I am adding lines to the control in the OnActivate mehtod of the first form that is displayed by the application. i.e. before any user interaction has taken place. After that I don't need to do anything except give the control focus and it will follow (scroll) as I add ne lines.

Epsylon,
Thank-you your solution worked although on reading through some of the other messages I chose the EM_SCROLLCARET because I actually wanted to follow the cursor.
Glad I could help, Thanks.