Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
how do I stop the listview scroll bar from readjusting after the listview repaints? I would like for the it to retain its current position.

thanks in advance,
Updated 30-Nov-11 11:39am
Sergey Alexandrovich Kryukov 30-Nov-11 15:10pm    
Again, tag your UI library: WPF, Silverlight, Forms, ASP.NET, what?!
Why would you like the scroll to retain the position? You see, when the number of element changes (is it the case?) the whole notion of "position" becomes "philosophical", especially of it gets smaller. What is the definition of "retain"?
fjdiewornncalwe 30-Nov-11 15:11pm    
As indicated, please identify the technology you are using, the ListView controls in these different technologies behave differently.
d.allen101 30-Nov-11 15:28pm    
Sorry...I'm using winForm. My listview is displaying approx 50 items but it holds maybe 100 or so. the items are coming from a db query that runs on a timer every second. if the user has scrolled all the way down to the bottom of the listview and is watching the last 50 or so entries when the listview repaints it scrolls back up to the top...actually it's repainting so fast every second that it won't even allow the enough time to scroll anywhere!

1 solution

Sorry it was goofy and very lazy of me to post this. I was clearing the the listview after each timer firing/update of the solution is: after the listview is initially populated I no longer clear it I simply overwrite the existing text. eg if(listview1.Items.Count > 0) { listview.Items[0].Text = "whatever"; etc...
Share this answer
LanFanNinja 30-Nov-11 18:24pm    
Well at least you figured it out.

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