holemania
asked on
VB.Net - For Loop Error
I am getting an error to look at my datagridview and if one of the column is empty to highlight the entire row. It is working but spitting an error at the end of the loop.
Here's my For loop to check the value.
At the end of the loop I get the following error:
Here's my For loop to check the value.
For Each row As DataGridViewRow In dgDetail.Rows
Dim service As String = row.Cells(4).Value.ToString
If service = Nothing Then
row.DefaultCellStyle.BackColor = Color.Red
End If
Next
At the end of the loop I get the following error:
ASKER
I did debug and it is going through empty row. Shouldn't it exit the loop if no rows left?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. Went with Ark's solution since that worked. Also thanks to Pawan for contributing.
<<Put a debug point after the loop, run the program>>
Debugging - Can you place your mouse on the dgDetail and check the values after the exception.
Hope it helps !