How to avoid a listview flickering?

Giovanni Montrone wrote in his Code Project article that the best way to avoid listview flicking is forcing it to use DoubleBuffer. He provides a new listview control that inherits from the classic one and adds a new method called SetExStyles() which allows setting the extended styles of the listview.
But I found a comment from Gabriel Szabo explaining how to have the same result without sub classing any control, but using Reflection :

PropertyInfo aProp = typeof(ListView).GetProperty("DoubleBuffered",
BindingFlags.NonPublic | BindingFlags.Instance);
aProp.SetValue(lvwControl, true, null);

(when lvwControl is the name of your listview control)

Many thanks Gabriel !!

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.