Updating a ListView RRS feed

  • Question

  • Is there an easy way to update the info in a ListView without having it redraw the entire line constantly?


    For example, I have a ListView control that displays pertinant data about objects that constantly update themselves. I'm using the ListView to dynamically display these objects (and their data) but the constant flashing from the redraw really annoys me. I know you can set it to OwnerDraw, or something like that, but I'm a little fuzzy on what exactly I'd have to do there.

    Friday, February 10, 2006 9:09 PM

All replies

  • Wrap the code that updates the ListView in calls to ListView.Begin/EndUpdate.
    Saturday, February 11, 2006 3:21 AM
  • I'm doing that currently, but the problem is I'm updating about once a second.


    I'm actually wondering if the ListView is the right control for what I'm doing. I'm letting the user dynamically create objects that have built-in timers and that update themselves with a status. I'm using the ListView to show all the objects and their current status, but the status changes quickly so it requires pretty fast updating. Also, the user needs to be able to select an object from the list and edit it. Any recommendations on a better way to display this?

    Monday, February 13, 2006 5:51 PM
  • Did you set the DoubleBuffered property to true?
    Monday, February 13, 2006 8:37 PM
  • Didn't know about the DoubleBuffered property. I went in and set it to true for form to try it out but I still get the flicker. Should it be set on the form?
    Monday, February 13, 2006 10:35 PM
  • Try setting DoubleBuffered on the ListView itself. How many items are you showing in the ListView? If there are a lot, and they are updating themselves individually, you probably wont be able to eliminate the flicker entirely. Consider having the ListView refresh itself once periodically for all objects, instead of having them individually refresh themselves.
    Monday, February 13, 2006 11:54 PM
  • Hello Kris,

    yes Genius is right. If you want to set the DoubleBuffer you have to extend the ListView since it is a protected method. This should help your problem if you don't have zillions of icons on the view.

    Tuesday, February 14, 2006 11:44 AM