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
Function 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
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.