Hi All,
I've looked everywhere and cannot find a reason for this. I'm essentially try ing to loop through every row in a datagridview, and trying to remove the entire row, if a certain cell's value matches another value. Please find the code below. This is working, however is skipping every other result, meaning half of the rows that should be removed are remaining in the datagridview. Could someone please advise as to what I'm doing wrong?
Dim Exclude As String
Dim Column As String
Dim Value As String
Dim ROW As DataGridViewRow
For Each line In Split(TXT_Filters.Text, vbNewLine)
Aud("Working On Filter : " & line)
If UBound(Split(line, ":")) = 2 Then
Exclude = Split(line, ":")(0)
Column = Split(line, ":")(1)
Value = Split(line, ":")(2)
Aud("Applying Filter : " & line)
Aud("Value to exclude : " & Value)
For Each ROW In DGV_Main.Rows
Aud("Found Row With Value : " & ROW.Cells(Column).FormattedValue)
If ROW.Cells(Column).FormattedValue = Value Then
Aud("Matches, Removing Line")
DGV_Main.Rows.Remove(ROW)
Aud("Removed Line, New Count: " & DGV_Main.Rows.Count)
Else
Aud("Not Matching, not removing")
Aud("Didn't Remove Line, New Count: " & DGV_Main.Rows.Count)
End If
Next
Aud("Finished working on filter : " & line)
End If
Next