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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.