How to prevent flickering in ListView when updating a single ListViewItem's text?

前端 未结 10 2132
囚心锁ツ
囚心锁ツ 2020-11-27 04:56

All I want is to update an ListViewItem\'s text whithout seeing any flickering.

This is my code for updating (called several times):

listView.BeginUp         


        
相关标签:
10条回答
  • 2020-11-27 05:57

    If you only want to update the text, simply set the changed SubItem's text directly rather than updating the entire ListViewItem (you've not said how you're doing your updates).

    The override you show is equivalent to simply overriding OnPaintBackground, which would be a "more correct" managed way to do that task, and it's not going to help for a single item.

    If you still have problems, we'll need clarification on what you've actually tried.

    0 讨论(0)
  • 2020-11-27 05:58

    Call the BeginUpdate() method on the ListView before setting any of the list view items and then only call EndUpdate() after all of the items have been added.

    That will stop the flicker.

    0 讨论(0)
  • 2020-11-27 06:02

    this will help:

    class DoubleBufferedListView : System.Windows.Forms.ListView
    {
        public DoubleBufferedListView()
            :base()
        {
            this.DoubleBuffered = true;
        }
    }
    
    0 讨论(0)
  • 2020-11-27 06:02

    Simple solution is this:

    yourlistview.BeginUpdate()

    //Do your update of adding and removing item from the list

    yourlistview.EndUpdate()

    0 讨论(0)
提交回复
热议问题