0

Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'.


hi i got this error message

Private Sub DataGridView1_RowHeaderMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.RowHeaderMouseDoubleClick
        'DataGridView1.DataSource = bs

        Dim i As Integer
        i = DataGridView1.CurrentRow.Index
        txtConID.Text = DataGridView1.Item(0, i).Value
        txtLname.Text = DataGridView1.Item(1, i).Value
        PictureBox1.Image = DataGridView1.Item(2, i).Value <-here!
    End Sub

i have an image datatype i want it when i click the rowheader to be displayed on my picturebox. how can i do this?

2
Contributors
1
Reply
5
Views
5 Years
Discussion Span
Last Post by rmeshack2012
0

PictureBox1.Image.FromFile(DataGridView1.Item(2, i).Value)

** .FromFile(String) - this function accepts the URL of the image in ur Drive in String

.Image() property of the picturebox accepts OBJECT and .VALUE() of the Datagrid returns a STRING. Reply to this thread for more explanations

Edited by rmeshack2012: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.