我有一个填充数据的datagridview。现在我想将所选数据的图像显示到图片框中。代码适用于文本和日期,无论我点击它的数据是什么,但不是在图像上。
我收到错误消息'Unable to cast object type 'System.Byte[]' to type System.Drawing.Image
'
下面的示例代码
Private Sub selected()
Private Sub selected()Try
If Me.dgvadt.Rows.Count > 0 Then
If Me.dgvadt.SelectedRows.Count > 0 Then
If Me.dgvadt.SelectedRows(0).Cells("idComplaints").Value Is DBNull.Value = True Then
Me.txtIDcomplaint.Text = ""
Else
Me.txtIDcomplaint.Text = Me.dgvadt.SelectedRows(0).Cells("idComplaints").Value
End If
If Me.dgvadt.SelectedRows(0).Cells("DateFiled").Value Is DBNull.Value = True Then
Me.txtDF.Text = ""
Else
Me.txtDF.Text = Me.dgvadt.SelectedRows(0).Cells("DateFiled").Value
End If
If Me.dgvadt.SelectedRows(0).Cells("AccountNumber").Value Is DBNull.Value = True Then
Me.txtAC.Text = ""
Else
Me.txtAC.Text = Me.dgvadt.SelectedRows(0).Cells("AccountNumber").Value
End If
If Me.dgvadt.SelectedRows(0).Cells("Attachment").Value Is DBNull.Value = True Then
Else
pbPicture.Image = Me.dgvadt.SelectedRows(0).Cells("Attachment").Value
End If
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
MessageBox.Show("Click to View", "PELCO III ", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub