Auto-scroll ListView
-
Hi there, Is there anyone know how to make a windows form listview control always automatically scroll to the last item when loading lots of items into the list? Thanks a lot. Frank
-
Hi there, Is there anyone know how to make a windows form listview control always automatically scroll to the last item when loading lots of items into the list? Thanks a lot. Frank
-
Try this, right after populating the list view: lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True that's it! Cheers, Pablo.ar
-
Thanks, Pablo.ar. But it does not work, because what I need it is to always show the last item while the items are loading. Frank
Just put that line right at the end (still, inside!) of the loop block: Do ...your block of code ...your block of code ...your block of code lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True Loop So, right before the loop loops, it will select (and scroll to) the last item. ;) Pablo.ar
-
Just put that line right at the end (still, inside!) of the loop block: Do ...your block of code ...your block of code ...your block of code lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True Loop So, right before the loop loops, it will select (and scroll to) the last item. ;) Pablo.ar
Hi Pablo Thanks for your reply. But I think you might be talking about some list control other than MS ListView, since ListView does not have ListItems property (while it does have Items property). And your statement can be: lvMyListOfItems.Items(lvMyListOfItems.Items.Count - 1).Selected = True This statement will select all the items after the loop completes. However, it can not auto-scroll the listview while loading items. It is another stupid MS control, since many other third-party controls can do it without any code. Meanwhile, kostasV provides a solution that meets my need. Thanks again for your time. Frank
-
Hi Pablo Thanks for your reply. But I think you might be talking about some list control other than MS ListView, since ListView does not have ListItems property (while it does have Items property). And your statement can be: lvMyListOfItems.Items(lvMyListOfItems.Items.Count - 1).Selected = True This statement will select all the items after the loop completes. However, it can not auto-scroll the listview while loading items. It is another stupid MS control, since many other third-party controls can do it without any code. Meanwhile, kostasV provides a solution that meets my need. Thanks again for your time. Frank
If you still want to give a try to the way I showed you, make sure you set the listview property 'Multiselect' to false. I think that's why the code I gave you didn't work, anyhow, you did get the solution in a better way. 1st class code there, kostasV! Pablo.ar
-
If you still want to give a try to the way I showed you, make sure you set the listview property 'Multiselect' to false. I think that's why the code I gave you didn't work, anyhow, you did get the solution in a better way. 1st class code there, kostasV! Pablo.ar