Double buffered ListBox

前端 未结 4 1456
轻奢々
轻奢々 2021-02-15 11:16

I have a CheckedListBox (WinForms) control (which inherits from ListBox; googling shows that the problem is with ListBox) that is anchored to all four sides of its form. When t

4条回答
  •  青春惊慌失措
    2021-02-15 11:29

    This used to be handled by sending the WM_SETREDRAW message to the control.

    const int WM_SETREDRAW = 0x0b;
    
    Message m = Message.Create(yourlistbox.Handle, WM_SETREDRAW, (IntPtr) 0, (IntPtr) 0);
    yourform.DefWndProc(ref m);
    
    // do your updating or whatever else causes the flicker
    
    Message m = Message.Create(yourlistbox.Handle, WM_SETREDRAW, (IntPtr) 1, (IntPtr) 0);
    yourform.DefWndProc(ref m);
    

    See also: WM_SETREDRAW reference at Microsoft Fixed Link

    If anyone else has used windows messages under .NET, please update this posting as necessary.

提交回复
热议问题