Scrolling TRichEdit and TListBox

Posted on 1998-08-09
Last Modified: 2010-04-04
I want to scroll RichEdit and TListBox components automaticly to the bottom when something is added..
How do I do that?
Question by:mortenmo

Accepted Solution

erajoj earned 50 total points
ID: 1361755
Here is an example of one way to solve it:

  MyString: string;
  MyString := 'Whatever';
  ListBox1.ItemIndex := ListBox1.Items.Add( MyString );
  RichEdit1.Lines.Add( MyString );

  //  RichEdit1.SelStart := RichEdit1.SelStart - 2; // optional, preceed the CR+LF

  // RichEdit1.SelStart := RichEdit1.SelStart - Length( MyString ) - 2; // optional, start of added string
  // RichEdit1.SelLength := Length( MyString );

  SendMessage( RichEdit1.Handle, EM_SCROLLCARET, 0, 0 );

Uncomment the commented lines to get variations on the richedit selections after adding.

/// John
LVL 10

Expert Comment

ID: 1361756
For the listbox, you can also use this way....

Listbox1.ItemIndex := Lo(listbox1.Items.count - 1);

Hope this helps a bit!

Viktor Ivanov

Author Comment

ID: 1361757
Thanks ;)

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 135
Error E2158 compiling with Delphi XE10 Seattle 2 99
CheckListBox usage 3 58
Tidtcpserver listening on multiports? 1 27
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question