Recorrer Datagrid
Enviado por pajaros • 24 de Septiembre de 2014 • 211 Palabras (1 Páginas) • 139 Visitas
For each Fila1 as DataGridViewRow in DataGridView1.Rows
Dim Añadir as Boolean = True
For each Fila2 as DataGridViewRow in DataGridView2.Rows
If Fila2.Cells("ItemID")=Fila1.Cells("ItemID") then
Fila2.Cells("cantidad").Value = Fila2.Cells("cantidad").Value + Fila1.Cells("cantidad").Value
Añadir = False
EndIf
If Añadir then
DataGridView2.Rows.Add (Fila1.Cells("ItemID").Value, Fila1.Cells("cantidad").Value
End If
Next
Next
For each Fila1 as DataGridViewRow in DataGridView1.Rows
Dim Añadir as Boolean = True
For each Fila2 as DataGridViewRow in DataGridView2.Rows
If Fila2.Cells("ItemID")=Fila1.Cells("ItemID") then
Fila2.Cells("cantidad").Value = Fila2.Cells("cantidad").Value + Fila1.Cells("cantidad").Value
Añadir = False
EndIf
If Añadir then
DataGridView2.Rows.Add (Fila1.Cells("ItemID").Value, Fila1.Cells("cantidad").Value
End If
Next
Next
...