How to scroll to the specified row/item in ListView control of .NET and VB6
Posted by Admin L in .NET Programming, VB6 Programming on 25-04-2012. Tags: .NET Programming Experience, VB6 Programming Experience
Author: Nosa Lee
Original Address: https://www.seeksunslowly.com/dot-net-vb6-listview-scroll-row
To reprint this article, please indicate the source, thank you.
_____________________________________
Sometimes, we need to scroll a row/item to a visual position in ListView control (.NET: View property = Details; VB6: View property = 3 – lvwReport).
For instance: display the search result, if there are too many rows/items and you do not scroll the result item to a visual postion, the Search functionality exists in name only.
It looks very complicated, and I thought that it maybe need API at first.
But, the resolve is very simple, just use ListView.TopItem property (in VB6 is ListViewItem.EnsureVisible method).
VB 2008 Example
[cc lang=”vbnet”]
lv.TopItem = lv.SelectedItems(0) ‘ lv is a ListView control.
[/cc]
VB6 Example
[cc lang=”vbnet”]
lv.ListItems(100).EnsureVisible ‘ lv is a ListView control.
[/cc]


