I am building a grid dynamically and want to have a delete image as the last displayed column.
The image displays fine on the row I add, but the new row doesn't have the image. What am I missing?
When I run the following code I get one row with the image and a second empty row with the 'missing image' icon:
Public Class Testing
Private dtData As New DataTable
Private Sub Testing_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadMyGrid()
End Sub
Private Sub LoadMyGrid()
Try
Dim img As New DataGridViewImageColumn
Dim inImg As Image = My.Resources.delete
img.Image = inImg
dtData.Columns.Add("LanguageId")
dtData.Columns.Add("Language")
dtData.Rows.Add(1, "English")
'--- Load the grid
With Me.dgv1
.Columns.Clear()
.DataSource = dtData
.Columns(0).Visible = False
dgv1.Columns.Add(img)
img.Width = 40
img.Name = "DELETE"
.ClearSelection()
End With
Catch ex As Exception
MsgBox("You hit an error")
End Try
End Sub
End Class
Thanks for any help!