Skip to content

Instantly share code, notes, and snippets.

@facebookegypt
Created July 3, 2020 15:04
Show Gist options
  • Save facebookegypt/0c873ddbdf8ffce900b1f908aa67da8c to your computer and use it in GitHub Desktop.
Save facebookegypt/0c873ddbdf8ffce900b1f908aa67da8c to your computer and use it in GitHub Desktop.
Resize Image in DataGridView Control in VB.Net
'Visual Basic Form
'Form1 (DataGridView1)
Public Class Form1
Private Sub DataGridView1_CellFormatting(sender As Object, _
e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
If e.RowIndex = -1 Or e.ColumnIndex = -1 Then Exit Sub
Dim Col_Name as String = ("ImageCol")
Try
If Not IsNothing(e.Value) Then
If DataGridView1.Columns(e.ColumnIndex).ValueType = GetType(Byte()) Then
Dim imageColumn = DirectCast(DataGridView1.Columns(Col_Name), DataGridViewImageColumn)
imageColumn.ImageLayout = DataGridViewImageCellLayout.Zoom
End If
End If
Catch ex As Exception
MsgBox("Error Display Image : " & ex.Message)
End Try
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment