Code to show image in datagrid view
I found this sample code on MSDN to show an image in a datagridview and it says that this same code can be used for any image. However I am having a problem getting it to work with jpeg. Can someone help me out?
Code:
Public Sub CreateGraphicsColumn()
Dim treeIcon As New Icon(Me.GetType(), "tree.ico")
Dim iconColumn As New DataGridViewImageColumn()
With iconColumn
.Image = treeIcon.ToBitmap()
.Name = "Tree"
.HeaderText = "Nice tree"
End With
dataGridView1.Columns.Insert(2, iconColumn)
End Sub
Re: Code to show image in datagrid view
I got it.
Code:
Dim AutoImage As New Bitmap("C:\myImage.jpg")
Dim imageColumn As New DataGridViewImageColumn()
With imageColumn
.Image = AutoImage
.Name = "Auto"
.HeaderText = "Snap Shot"
End With
dgwPics.Columns.Insert(1, imageColumn)
With dgwPics
.Columns.Item(1).Width = 300
.Rows.Item(0).Height = 300
End With
Now my only issue is that I want to make all my Row heights 300 instead of just the first one as I have in the code.