I have a windows form. It contains several datagridviews on it. At some point, the user can press a button which updates the datagridviews. When they do, they can usually sit and watch the datagridview redraw itself, one row at a time. I’d like for the control to not paint until its ‘done’, that is, I’d like a way to tell the control to
Control.SuspendRedraw() this.doStuff() this.doOtherStuff() this.doSomeReallyCoolStuff() Control.ResumeRedaw()
I’ve seen the SuspendLayout / ResumeLayout functions, but they do nothing (they seem to be more related to resizing/moving controls, not just editting their datavalues?)
There are a couple of things that you can try:
First, try setting the DoubleBuffer property of the DataGridView to true. This is the property on the actual DataGridView instance, not the Form. It’s a protected property, so you’ll have to sub-class your grid to set it.
I’ve seen a lot of small draw updates take a while with the DataGridView on some video cards, and this may solve your problem by batching them up before they are sent off for display.
Another thing you can try is the Win32 message WM_SETREDRAW
Elsewhere in your code you’d have