1

TListbox.topIndex is not apparent in Delphi xe5. How do I perform a similar function ? I would like to have the listbox scroll so that the selected item is at the top of the listbox.

I have found other examples where I can set ListBox.itemIndex, but that doesn't scroll so that the selected item is at the top of the listbox.

Thank you in advance.

LU RD
  • 34,438
  • 5
  • 88
  • 296
ThisGuy
  • 1,405
  • 1
  • 24
  • 51

2 Answers2

2

On Windows, the VCL TListBox has a public TopIndex property, which internally uses the LB_SETTOPINDEX message.

There is no equivalent in the FireMonkey TListBox. The only option I see would be to call the ListBox's ScrollTo() method to manually scroll the ListBox so the target list item appears where you want it to be.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
2

I have used this code which works:

var
  THackListBox = type TListBox;
begin
  THackListBox(ListBox1).VScrollBar.Value := 0;

The VScrollBar property is protected but this method exposes the property and allows the value to be set to zero.

J__
  • 3,777
  • 1
  • 23
  • 31