将图像从DataGridView
绑定到PictureBox
时出现问题,我收到以下错误
无法转换类型为' System.String'的对象输入' System.Byte []'
这是我的代码:
Private Sub BindToText()
With dgv_EmployeeMainFile
...
Dim bytes As [Byte]() = .CurrentRow.Cells(31).Value
Dim ms As New MemoryStream(bytes)
PictureEmp.Image = Image.FromStream(ms)
End With
End Sub
答案 0 :(得分:0)
假设Cells(31)包含Unicode字符,那么您可以使用:
System.Text.Encoding.Unicode.GetBytes(str)
供参考:https://www.dotnetperls.com/convert-string-byte-array-vbnet