asked on
Try
For Loop1 As Integer = (DataGridView2.Rows.Count - 2) To 0 Step -1
For Loop2 As Integer = (DataGridView2.Rows.Count - 2) To Loop1 + 1 Step -1
If compare_row(DataGridView2.Rows(Loop1), DataGridView2.Rows(Loop2), DataGridView2.Columns.Count) Then
DataGridView2.Rows.RemoveAt(Loop2)
End If
Next
Next
Catch ex As Exception
MsgBox("error1 in button click" + vbCrLf + ex.Message)
End Try
FunctionFunction compare_row(row1 As DataGridViewRow, row2 As DataGridViewRow, len As Integer) As Boolean
Dim temp_bool As Boolean = True
For i = 0 To len - 1
temp_bool = temp_bool And (row1.Cells(i).Value = row2.Cells(i).Value)
Next
Return temp_bool
End Function