Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

method to keep list of strings scrolled to bottom?

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I want to display a list of many rows of texts in either a stringgrid, listview or memo, and to add to that list one row at a time by entering data.
But I want the list to stay scrolled the bottom of the list, so you can always see the last item just entered.
Can this be done? How?


Steve (Delphi 2007 & XP)
 
for a TMemo that would be :

Code:
  // go to the last line
  Memo1.SelStart := MaxInt;
  // set line into view
  SendMessage(Memo1.InnerControl.Handle, EM_SCROLLCARET, 0, 0);


I will need to look up TListview and TStringGrid. :)

/Daddy


-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
thanks for the reply Daddy.
When I experiment with it though, the editor is telling me that 'Tmemo does not contain a member names InnerControl' ?

I had an error on the EM_ScrollCaret too, until I guessed it needed Messages added to the Uses statement.
That was a pure guess, based on my own reasoning. I couldn't see a way of deducing that from Help?

Can I just check something.
You used MaxInt instead of looking for the the number of lines in the Memo1?
Just goto the the highest line that's possible, but if not that many lines existing, the memo will just show the highest, right?
Assuming I am correct, that bit I can understand OK.

But the sendmessage, how on earth could I work out for myself without knowing, how to do that?
Now you've told me I can look it up in Help and see what's going on, but I'd like to be able to reason the answer for myself, at least at some point.

I hate having to ask for help too often, as I like to learn and find my own way, and whilst I know I am lowly white or yellow belt, among Black Belt 5th dan's, but I'm kind of floundering in the how do I find out for myself stage...

I have googled a fair bit of stuff and sorted myself out based on what I have found though.

Steve (Delphi 2007 & XP)
 
Can I just check something.
You used MaxInt instead of looking for the the number of lines in the Memo1?
Just goto the the highest line that's possible, but if not that many lines existing, the memo will just show the highest, right?

Right!

you won't find the EM_SCROLLCARET thing in delphi. One thing you need to keep in mind, is that most VCL controls are based upon Microsoft Common Control library. That means that we are talking Windows, and windows is a messaging OS so no surprise about the SendMessage. This also means that these things are very well documented on the side of MS. check out their technet website, it contains a wealth of information about windows and stuff. Googling things like 'delphi memo last line' will surely pop up the correct solution.

there are some websites out there that contain a ton of these tips. worth checking out is


Like you I, learnt all this stuff by myself, but also by learning from others. Keep it up ;)

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Glad I'm following in your footsteps then, there's hope!

Sites I also use a lot apart from this one and the Torry pages are:
and

I can usually find snippets on these enough to deduce what I want to do.
For some reason, StrigGrid and ListView seem harder to track down the basics for.
I am struggling to achieve my goal with these two. I probably will use just one, just want to investigate the best one before I get stuck in to the program proper..


Steve (Delphi 2007 & XP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top