المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : DataGridView CellPainting (selected cells only) [modified]



C# Programming
05-12-2009, 10:00 AM
I have noticed that updating a DGV (only a couple of cells), still has the application repainting the whole grid when an Update occurs! I have an application with up to 6 DataGrids with 5 columns and up to 40 rows. As I step through my loaded database, I see results changing in real time on the DataGrids but it is very slow as it sweeps across the screen. Flicker is certainly noticeable on cell values that have not changed.

I don't see the need to repaint up to 1200 cells when only a few of them have actually changed (value & BackColor).
Even on a blank grid, I have stepped through the CellPainting Event when only the selected cell has changed yet the whole grid is still repainted.

When I take care of the CellPainting myself, only the cells I want to update are modified some flicker is still visible but the performance is incredible. However, the other cells are messed up from other windows when they get on top or when my window is resized.
I have noticed the ClipBounds property from the DataGridViewCellPaintingEventArgs informs you of the area that needs to be painted.

Is there something I am missing about the DataGridView? Any help much appreciated!

john1166

modified on Tuesday, May 12, 2009 1:47 AM