Monday, May 30, 2011

Flicker free controls: ListView

.Net Flicker Fee Controls 


Here are the steps to use this control:
1. Add new class "NonFlickerListView" to your C# application.
2. Replace auto generated class code with C# code shown below.
3. Use NonFlickerListView object instead of ListView object in your application.
   
public partial class NonFlickerListView : ListView
    {
        public NonFlickerListView()
        {
            this.GetType().GetProperty("DoubleBuffered",
System.Reflection.BindingFlags.NonPublic |                                                      System.Reflection.BindingFlags.Instance
).SetValue(this, true, null);
        }

            protected override void WndProc(ref Message messg)
        {
            if ((int)0x0014 == messg.Msg) // if message is is erase background
            {
                messg.Msg = (int)0x0000; // reset message to null
                return;
            }
            base.WndProc(ref messg);

        }
    }

No comments:

Post a Comment