Created
July 3, 2020 15:04
-
-
Save facebookegypt/0c873ddbdf8ffce900b1f908aa67da8c to your computer and use it in GitHub Desktop.
Resize Image in DataGridView Control in VB.Net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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