我收到错误
无法转换'字符串'到byte []
我发现了问题..图像是问题,在双击gridview上的任何特定记录后,它不会以entry_jewelry
形式显示。
我有两种形式:
我尝试了很多将图像从gridview转回到"珠宝的入口"
它不起作用请帮助我。
我的gridview代码:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
S_Jewelry myForm = new S_Jewelry();
myForm.Stock_Type.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
myForm.txt_stock_no.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
myForm.txt_qty.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
myForm.combo_itemk_description.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
myForm.combo_item_type.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
myForm.txt_no_of_gems.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
myForm.txt_gem_type.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();
byte[] pic = (Byte[])dataGridView1.CurrentRow.Cells[8].Value.ToString();
MemoryStream stream = new MemoryStream(pic);
myForm.pb1.Image =Image.FromStream(stream);
// myForm.pb1.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
myForm.txt_gem_weight.Text = this.dataGridView1.CurrentRow.Cells[9].Value.ToString();
myForm.txt_no_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString();
myForm.txt_other_gems.Text = this.dataGridView1.CurrentRow.Cells[11].Value.ToString();
myForm.txt_weight_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[12].Value.ToString();
myForm.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
myForm.ShowDialog();
}
答案 0 :(得分:0)
尝试使用图像源加载图片
//save image location in gridview (C:\\folder\\image.jpg)
string pic = dataGridView1.CurrentRow.Cells[8].Value.ToString();
myForm.pb1.Image =Image.FromFile(pic);