Link to home
Start Free TrialLog in
Avatar of comsult
comsult

asked on

VIsual Studio 2005 (VB Winform) Datagrid FOR Iteration Very Slow

In a VS2005, VB Windows app we populate a datagridview from a SQLCE DB.

The grid has a check box ("IsSelected") which allows the user to select individual rows or they can select all if required.

Once the selection has been made, they use a combobox outwith the grid and a button to alter the value in one column (BINPrice). As there can be as many as 5000 rows in the grid, this is taking several minutes using the following FOR :

 Dim id As Integer
            For id = 0 To DataGridView1.Rows.Count - 1
                If DataGridView1.Rows(id).Cells("IsSelected").Value = True Then
                    DataGridView1.Rows(id).Cells("BINPrice").Value = txtApplyBINPrice.Text
                Else
                    MsgBox("To be added later")
                End If
            Next id

As we fill the grid from the DB in around four seconds, surely there must be a quicker way of doing this ? Is it possible to select the whole column and then apply the value from the combobox ?

Any help will be greatly appreciated, thank you.
ASKER CERTIFIED SOLUTION
Avatar of slado2
slado2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of comsult
comsult

ASKER

Thank you very much, that is at least five times quicker.