I have an datagridview with play image ImageColumn and if user click play icon then CellClick Event set "Stop" image from Resources.
Private Sub dg1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dg1.CellClick
dg1.Rows(e.RowIndex).Cells(3).Value = New Bitmap(app1.My.Resources.stop)
End Sub
But i need get user what image click (Play or Stop) How to get datagridview image name for Cellclick event? I tried
dg1.Rows(e.RowIndex).Cells(3).Value.ToString()
But returned "System.Drawing.Image" value i need image value. Sorry for my bad english.
Thanks for interest
This is how I would get the image. First check if the cell you click is of type
DataGridViewImageCell
. If it is, try casting theValue
property as whatever image format you are expecting.Alternatively, you could save the bitmap as a class level variable:
then in the
CellClick
method: