How to avoid flickering in treeview
how to avoid flickering in treeview,
when some property of nodes is gettng up开发者_开发百科dated, or the node is added
Try the following:
try
{
    treeView.BeginUpdate();
    // Update your tree view.
}
finally
{
    treeView.EndUpdate();
}
I was fighting this, too. Here is my solution for those of you searching out there. Add this to your treeview subclass.
    private const int WM_VSCROLL = 0x0115;
    private const int WM_HSCROLL = 0x0114;
    private const int SB_THUMBTRACK = 5;
    private const int SB_ENDSCROLL = 8;
    private const int skipMsgCount = 5;
    private int currentMsgCount;
    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_VSCROLL || m.Msg == WM_HSCROLL)
        {
            var nfy = m.WParam.ToInt32() & 0xFFFF;
            if (nfy == SB_THUMBTRACK)
            {
                currentMsgCount++;
                if (currentMsgCount % skipMsgCount == 0)
                    base.WndProc(ref m);
                return;
            }
            if (nfy == SB_ENDSCROLL)
                currentMsgCount = 0;
            base.WndProc(ref m);
        }
        else
            base.WndProc(ref m);
    }
I got the idea here: treeview scrollbar event
Basically I am just ignoring a significant percentage of the scroll messages. It reduces flicker a lot for me.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论