Question Slow Loop needs speeding up

eurika

New member
Joined
Mar 4, 2011
Messages
2
Programming Experience
Beginner
Hi all,
hopefully one of you will be able to speed this thing up for me,

I have two datagrids, one stores the details of people aka dgvpeople and the other stores the groups aka dgvgroups. by selecting rows within the dgvpeople and then adding to group it will save these to the group cell which I have working, I also have the remove part of this working. however I have over 1000 people in the dgvpeople and when the remove part is run the loop takes quite some time to complete I have attached the code below is there a quicker way to complete this loop, so that the screen does not freeze the gui for the user for a period of short period of time.


it is using stringbuilder ie sb.

###################################################
Code below

For i = 0 To dgvpeople.RowCount - 1
For r = 0 To selectedRowCount - 1

'Below searches and then replaces all <Row Index> found to "" in effect removing them

If SelCel.Contains("<" + dgvpeople.SelectedRows(r).Index.ToString() + ">") Then
NewCel = ("<" + dgvpeople.SelectedRows(r).Index.ToString() + ">")
'//////////////////////////////////////////////////////////////////////////////
sb.Replace(NewCel, "").ToString()
GRPdgv.CurrentCell.Value = sb.ToString
SelCel = sb.ToString
'/////////////////////////////////////////////////////////////////////////////

End If
Next r
Next i
 
re-thought this and started again from scratch and now sorted, i was doing the double loop when not needed simply changed the selectedrows to rows(i) could then remove the second loop and now is quicker than a quick thing on a quick day.

THIS IS RESOLVED .. not sure how to mark this in the forum as resolved..
 
Back
Top