WinForms.DataGridView VirtualMode Collapsing rows

207 Views Asked by At

I am working on a WinForms Application, that have a DataGridView, this Control emulates a TreeView, so the RowCount changes drastically. I am having a performance issue when collapsing rows...

Example:

// dataGrid.VirtualMode = true;
// dataGrid.RowCount = 100.000;
dataGrid.RowCount = 2; // Is too Slow!
1

There are 1 best solutions below

0
Leo On BEST ANSWER

Since you using VirtualMode, it is usually much faster to do like this:

dataGrid.Rows.Clear();
dataGrid.RowCount = 2;