Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I have a listview(with Scrollable = true) in my form and I'm populating it using a loop. In the loop I call Application.DoEvents() and then I add the current item( listview.add(...) ), so far so good.

If later I try to add some more items without clicking/pressing anything the listview behaves normally, but if I scroll using the mouse wheel while it's still adding the items the listview auto-scrolls to the top each time an item is added.

Long story short: How can I stop it from auto-scrolling to the top when an item is added?

Note: this doesn't happen if I use the scrollbar, the arrow keys or page up/down while it's still adding items only with the mouse wheel.
Posted
Updated 1-Jun-13 8:58am
v2

1 solution

After adding the item, call the item.EnsureVisible() routine, replacing item with your item name. This will always scroll to the newest item, if you don't want it to scroll at all then its a different problem.
 
Share this answer
 
Comments
mostwanted4 2-Jun-13 4:22am    
I was aware of that function, but I don't want to scroll at all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900