Avoid Flickering in Windows Forms?

前端 未结 3 1711
梦如初夏
梦如初夏 2020-12-15 00:08

Double buffering not working with combo-box. is there any another methods to avoid flickering in windows forms?

i have one windows form with number of panels in it.

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 00:49

    Solution #1:
    Use ComboxBox.BeginUpdate() before you add items. This will prevent the Control from repainting the ComboBox each time an item is added to the list. After adding the items, you can use ComboBox.EndUpdate() to repaint.

    Solution #2

    private void EnableDoubleBuffering()
    {
        this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
    }
    

提交回复
热议问题