Select All button too slow updating grid

jimbaloo

Member
Joined
Jun 20, 2007
Messages
7
Programming Experience
Beginner
Hi,

I have a windows forms app that contains a datagridview, with two filtered columns, some textbox columns, and a checkbox column. The filtering on the dgv is accomplished by using dropdowns on the column headers of the two filterable headers and this happens reasonably quickly.
My problem comes when I try to set the value of all the checkboxes to either checked or not checked. If I have a small number of rows in the dgv then each check operation takes about .0015 of a second. If I have a large number of rows that time jumps to 1.5 seconds per row. When I use the filters the dgv updates in about 2 seconds. I am at a loss.
The code I use to update the dgv checkbox column is:
VB.NET:
            If btnSelectRecords.Text = FormConstants.ControlConstants.DESELECT_ALL_RECORDS Then
                For Each row As DataGridViewRow In dgvLoanRecords.Rows
                    row.Cells(FormConstants.GridViewConstants.SELECTED).Value = False
                Next
                btnSelectRecords.Text = FormConstants.ControlConstants.SELECT_ALL_RECORDS
            Else
                For Each row As DataGridViewRow In dgvLoanRecords.Rows
                    row.Cells(FormConstants.GridViewConstants.SELECTED).Value = True
                Next
                btnSelectRecords.Text = FormConstants.ControlConstants.DESELECT_ALL_RECORDS
            End If

Can someone point me in the right direction to speed this process up.

Thanks

Jim
 
Last edited:
Try calling BeginLoadDate on the underlying table, then update the rows directly. DOnt go via the grid. Finish with EndLoadData..
 
Back
Top