DataGridViewImageColumn displays incorrectly - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

DataGridViewImageColumn displays incorrectly

jwbutlerjwbutler Posts: 16Member
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.

Me.TableAdapter.Fill(Me.DataSet.ViewName)
UpdateAuthStatusImage(GridView)
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)
Else
Row.Cells(0).Value = Me.ilImages.Images(7)
End If
Next
GridView.Refresh()
End Sub

Thanks,
Sign In or Register to comment.