Horrible redraw performance of the DataGridView on one of my two screens

后端 未结 9 1940
情话喂你
情话喂你 2020-11-28 03:30

I\'ve actually solved this, but I\'m posting it for posterity.

I ran into a very odd issue with the DataGridView on my dual-monitor system. The issue manifests its

9条回答
  •  执念已碎
    2020-11-28 04:17

    You just need to make a custom class based off of DataGridView so you can enable its DoubleBuffering. That's it!

    
    class CustomDataGridView: DataGridView
    {
        public CustomDataGridView()
        {
            DoubleBuffered = true;
        } 
    }
    

    As long as all of my instances of the grid are using this custom version, all is well. If I ever run into a situation caused by this where I'm not able to use the subclass solution (if I don't have the code), I suppose I could try to inject that control onto the form :) (although I'll be more likely to try using reflection to force the DoubleBuffered property on from the outside to once again avoid the dependency).

    It is sad that such a trivially simple thing ate up so much of my time...

    Note: Making the answer an answer so the question can be marked as answered

提交回复
热议问题