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

The accepted answer works, but is quite lengthy, and deriving from the control (like mentioned in the other answers) just to enable double buffering is also a bit overdone. But fortunately we have reflection and can also call internal methods if we like to (but be sure what you do!).

Be encapsulating this approach into an extension method, we’ll get a quite short class:

public static class ControlExtensions
{
    public static void DoubleBuffering(this Control control, bool enable)
    {
        var method = typeof(Control).GetMethod("SetStyle", BindingFlags.Instance | BindingFlags.NonPublic);
        method.Invoke(control, new object[] { ControlStyles.OptimizedDoubleBuffer, enable });
    }
}

Which can easily be called within our code:

InitializeComponent();

myListView.DoubleBuffering(true); //after the InitializeComponent();

And all flickering is gone.

Update

I stumbled on this question and due to this fact, the extension method should (maybe) better be:

public static void DoubleBuffered(this Control control, bool enable)
{
    var doubleBufferPropertyInfo = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
    doubleBufferPropertyInfo.SetValue(control, enable, null);
}

Leave a Comment