I am not too sure if this is easy or not but I have a datagrid with a return date field. All I want to happen is if any of the dates in the grid are before the current date Datetime.Now then turn a picturebox to visible. I have had a little play around but cannot seem to crack it. Any help on this would be great

Dim dr As New DataGridViewRow

        For i As Integer = 0 To dgLinenStock.Rows.Count - 1

            dr = dgLinenStock.Rows(i)

        If (dr.Cells("ReturnDate").Value = Nothing) And (dr.Cells("ReturnDate").Value << DateTime.Now) Then

            pbRed.Visible = True

        End If

If Returndate is empty (not specified) or if it's not a valid date or
less than today's date then the picture box will be visible.

For i As Integer = 0 To dgLinenStock.Rows.Count - 1

    dim returnDate as Date = dgLinenStock.Item("Returndate", i).Value

    If (returnDate = Nothing) OrElse (Not IsDate(returnDate)) OrElse (returnDate < DateTime.Now.Date) Then
        'pbRed.Visible = True
        'Exit For
        'If you want to show an error for each line, then use this
        dgLinenStock.Rows(i).ErrorText = "Returndate should be greater than today's date"

        'Clear the error
        dgLinenStock.Rows(i).ErrorText = ""

    End If


Hi Jade
Thank you very much for the updated code. The only problem is I dont want the picture box to be visable when the datagrid is empty. It seems that the picture is always visable when the form loads. The datagrid always shows one blank record. can this be removed??

No problem :)

dgLinenStock.AllowUserToAddRows = False

Hi Jade, Thank you so much for that it works a treat!!