Recent

Author Topic: How to ensure last line of TListBox is showing?  (Read 5702 times)

tech-pro

  • Full Member
  • ***
  • Posts: 173
    • Tech-Pro.net
How to ensure last line of TListBox is showing?
« on: February 01, 2008, 06:58:08 pm »
I have a debug window that is showing the communication in and out of the serial port. The data is displayed in a TListBox and I need to scroll the listbox so that the last line of data is always showing.

I know that setting TopIndex will force the listbox to show the last entries, but I can't see how to determine how many lines fit in the window. Under Windows, it is easy, because the font is standard and the number of lines probably won't change, so I could hard code it. But this program will be compiled for Linux as well and the font can be changed by the user.

I thought ItemHeight might give the height of a line in pixels, which I could devide into the list box height, but under Windows anyway (which I'm working in now) it appears to return the value zero.
Julian

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: How to ensure last line of TListBox is showing?
« Reply #1 on: February 07, 2008, 09:48:43 pm »
Code: [Select]

listbox1.items.add(inttostr(listbox1.items.count+1));//adds an item
listbox1.itemindex := listbox1.items.count -1;//selects the last item

 

TinyPortal © 2005-2018