Domanda

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.

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top