We help IT Professionals succeed at work.
Get Started

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

comsult
comsult asked
on
459 Views
Last Modified: 2013-11-26
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.
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE