Reputation: 1415
I have a delphi iOS application via Delphi xe5. on Form1, I have a button that generates results for a Listbox in form2 and then shows form2 after loading the items for that box. My issue is that when I go back to form1, and load results again: this time when Form2 appears, the listbox's display is in the middle of the screen. Meaning, instead of displaying results starting from the top, results are being displayed mid-way down the whole list of contents.
How do I programmatically have the list box scroll to the top of the results? Thank you
Upvotes: 2
Views: 2416
Reputation: 3837
I found that setting ItemIndex := 0 only worked if the user had clicked on a listbox item while viewing the list. Instead, I have used this code and it is working every time:
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.
Upvotes: 1
Reputation: 17108
Just set the listbox's ItemIndex to be zero:
Listbox1.ItemIndex := 0
Upvotes: 2