PDA

View Full Version : سوال: نمایش عکس داخل pictureBox از Datagrid



Iran58
یک شنبه 13 دی 1394, 18:24 عصر
سلام
چگونه می توانم یک عکس داخل pictureBox از روی ستونهای یک دیتاگرید ست کنم

( عکس را بصورت varbinary(MAX) ذخیره می کنیم )

abdullah20
یک شنبه 13 دی 1394, 18:29 عصر
byte[] arrPic = (byte[])(dataGridView1.CurrentRow.Cells[i].Value);
MemoryStream ms = new MemoryStream(arrPic);
pictureBox1.Image = Image.FromStream(ms);
ms.Close();

Iran58
یک شنبه 13 دی 1394, 18:38 عصر
byte[] arrPic = (byte[])(dataGridView1.CurrentRow.Cells[i].Value);
MemoryStream ms = new MemoryStream(arrPic);
pictureBox1.Image = Image.FromStream(ms);
ms.Close();
باسلام
این کدرا امتحان کرده بودم
ارور زیر را می دهد
Unable to cast object of type 'System.Data.Linq.Binary' to type 'System.Byte[]'.

ژیار رحیمی
دوشنبه 14 دی 1394, 07:23 صبح
سلام تبدیل به آرایه کن ببین مشکل حل میشه

byte[] arrPic = (dataGridView1.CurrentRow.Cells[i].Value).ToArray();

ASKaffash
دوشنبه 14 دی 1394, 07:40 صبح
سلام
شبیه این کد :

this.pictureBox1.Image = (Image)this.dataGridView2[this.MyImageCol.Name, this.dataGridView2.CurrentCell.RowIndex].Value;

Iran58
چهارشنبه 16 دی 1394, 21:59 عصر
سلام
شبیه این کد :

this.pictureBox1.Image = (Image)this.dataGridView2[this.MyImageCol.Name, this.dataGridView2.CurrentCell.RowIndex].Value;

سلام
استاد
this.MyImageCol.Name,
نفهمیدم میشه بیشتر توضیح بدهید