Slow DataGridViewRow performance in .NET C # application

I am trying to understand some kind of behavior in an application that I support. Excerpt:

foreach (DataGridViewRow pGridRow in grdEmail.Rows)
{
    pGridRow.Cells[0].Value = chkSelectAll.Checked;
    pCount = pGridRow.Index + 1;
}

Typically, you try to select all rows in a grid (check the box) when you click the Select All check box.

When a grid has several rows (a hundred or so), it works beautifully. However, when I have about 5,000 lines in it, this thing scans. The command pGridRow.Cells[0].Value = chkSelectAll.Checkedtakes a second or so (in time, placing Console.prints above and below it).

Any idea would be appreciated in resolving this issue.

+3
source share
4 answers

. . . ( 5000, .)

+1

:

grdEmail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
grdEmail.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;

, DataGridView , .

+1

5000 ?

? ?

0

( ) , , .

//assuming datasetFoo.Tables(0) is the DataSource of the DataGridView
foreach (DataRow rowFoo in datasetFoo.Tables(0) { 
        rowFoo ("Sel") = chkSelectAll.Checked; 
    } 
0

Source: https://habr.com/ru/post/1706698/


All Articles