DataGridViewImageColumn displays incorrectly

I have a DataGridView that is filled with by a DataSet. I have added an unbound DataGridViewImageColumn so I can display an image in the 1st cell. Once the TableAdapter.Fill method is executed I iterate over all the rows and update the 1st cell's value to a value from an image list. Then I execute the DataGridView.Refresh. This work 90% of the time but the other 10% of the time the image designated in the NullValue property is displayed. Can anyone recommend a fix? Below is a code extract.

Private Sub UpdateAuthStatusImage(ByRef GridView As DataGridView)
Dim StartDate As Date
Dim EndDate As Date
For Each Row As DataGridViewRow In GridView.Rows
StartDate = Row.Cells(5).Value
EndDate = Row.Cells(6).Value
If StartDate <= Date.Today And Date.Today <= EndDate Then
Row.Cells(0).Value = Me.ilImages.Images(6)
Row.Cells(0).Value = Me.ilImages.Images(7)
End If
End Sub

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!