1

I'm using datagridview in windows application developed in C# VS2005 .net 2.0.

Datagridview is provided a list of business objects. It take annoying delay of 2-3 seconds before starting displaying the rows in datagridview in falling-curtain fashion. When I switch back to my application from any other window it start repaint process in the same falling-curtain fashion. This is quite annoying. Plz someone help me sort this out!

Emad Suria
  • 31
  • 4
  • Can you reduce the code to the minimum that repeats the problem and post it - or just post what you think are the relevant sections. – ChrisF Feb 16 '10 at 12:14
  • The most likely explanation is that you are going back to the data source to repopulate the grid every time you repaint the grid. – ChrisF Feb 16 '10 at 12:15
  • 1
    How many rows did you stuff into that grid? – Hans Passant Feb 16 '10 at 12:28

1 Answers1

1

I don't know why it works, but setting the DataGridView control to double-buffered works an absolute treat. Make sure the DoubleBuffered property on the host-form is false also.

After doing this, my grid control went from redrawing so slowly (regardless of data-volume) that you could almost count the cells as they went in, - to redrawing as quick as any other control.

The DoubleBuffered property is protected on the DataGridView, so you will need to create a derived class and set the property there, eg:

class DoubleBufferDataGrid : DataGridView
{
    public DoubleBufferDataGrid()
        : base()
    {
        this.DoubleBuffered = true;
    }
}
Simon Bridge
  • 1,306
  • 1
  • 11
  • 5