iosdelphilistboxdelphi-xe5firemonkey-fm3

How to dynamically scroll in Tlistbox Delphi xe5


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.


Solution

  • 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.