Results 1 to 2 of 2

Thread: Code to show image in datagrid view

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    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

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width