简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM