I am trying to format some datagridview rows based on comparing them with other rows.
Here is the code I have so far.
For Each row As DataGridViewRow
You need an inner For Loop
if you want to have each item (row) iterated through and compare itself vs every other item in the list (grid).
For Each rowOuter As DataGridViewRow In DaisyServicesForm.DataGridView1.Rows
For Each rowInner As DataGridViewRow In DaisyServicesForm.DataGridView1.Rows
If rowOuter.Cells("UnitCost").Value = rowInner.Cells("UnitCost").Value And
(rowOuter.Cells("FromDate").Value <= rowInner.Cells("ToDate").Value And rowOuter.Cells("ToDate").Value >= rowInner.Cells("FromDate").Value) Then
rowOuter.DefaultCellStyle.ForeColor = Color.Blue
End If
Next
Next
You probably need to check the if statement I have there, but the idea should work. Also, you need to add a check so see if it the row is checking itself.