Hi guys,
I am writing a for loop where I am transferring one record from one datagridview to another datagridview. I am actually removing the row from the source datagridview and this is causing the problem. please see code below.
Removing the row is causing the problem since it is decreasing the number of rows in the source datagridview. please advise.
thanks
Ashley
I am writing a for loop where I am transferring one record from one datagridview to another datagridview. I am actually removing the row from the source datagridview and this is causing the problem. please see code below.
Code:
For i = 0 To dgvlistitemtobout.Rows.Count - 1
noofrows = dgvitemsout.RowCount
MsgBox(dgvlistitemtobout.Rows(i).Cells(0).Value)
If dgvlistitemtobout.Rows(i).Cells(0).Value = True Then
If dgvlistitemtobout.Rows(i).Cells(4).Value = 1 Then
dgvitemsout.Rows.Insert(noofrows, New Object() {dgvlistitemtobout.Rows(i).Cells(1).Value, dgvlistitemtobout.Rows(i).Cells(2).Value, dgvlistitemtobout.Rows(i).Cells(3).Value, dgvlistitemtobout.Rows(i).Cells(4).Value})
dgvitemsout.Rows(noofrows).HeaderCell.Value = (noofrows + 1).ToString
dgvlistitemtobout.Rows.RemoveAt(i)
End If
End If
Next
thanks
Ashley