Solved

Scrolling TRichEdit and TListBox

Posted on 1998-08-09
3
278 Views
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?
0
Comment
Question by:mortenmo
3 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
Comment Utility
Hi,
Here is an example of one way to solve it:

var
  MyString: string;
begin
  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
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
For the listbox, you can also use this way....

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

Hope this helps a bit!

Regards,
Viktor Ivanov
0
 
LVL 1

Author Comment

by:mortenmo
Comment Utility
Thanks ;)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now