[ Mr. Rejn @ 11.04.2007. 12:51 ] @
Kako vezujete PictureBox za polje koje sadrzi jpeg slike na SQL serveru (u
mom slucaju je Firebird)? Ovakav pokusaj:
Code:

DataTable dt = new DataTable();
fbDA3.Fill(dt);
this.openGrid1.DataSource = dt;
openGridPictureBox1.DataBindings.Add(new Binding("Image", dt, "FOTO"));//FOTO je ime kolone

daje ovo:
Code:

Exception System.FormatException was thrown in debuggee:
Cannot format the value to the desired type.

Negde sam nasao ovu f-ju za formatiranje:
Code:

using System.IO;
...
private void PictureFormat(object sender, ConvertEventArgs e)
{
    Byte[] img = (Byte[])e.Value;
    MemoryStream ms = new MemoryStream();
    int offset = 78;
    ms.Write(img, offset, img.Length - offset);
    Bitmap bmp = new Bitmap(ms);
    ms.Close();
    e.Value = bmp;
}

tako da gornji kod sada izgleda ovako:
Code:

DataTable dt = new DataTable();
fbDA3.Fill(dt);
this.openGrid1.DataSource = dt;
Binding imageBinding = new Binding("Image", dt, "FOTO",true);
imageBinding.Format += new ConvertEventHandler(this.PictureFormat);
openGridPictureBox1.DataBindings.Add(imageBinding);

ali sada izbacuje ovo:
Code:

Exception System.ArgumentException was thrown in debuggee:
Item has already been added.

a IDE pokazuje na liniju: openGridPictureBox1.DataBindings.Add(imageBinding);
[ miodrag77 @ 11.04.2007. 14:09 ] @
probaj ovim linijama da zamenis mesta

Binding imageBinding = new Binding("Image", dt, "FOTO",true);
imageBinding.Format += new ConvertEventHandler(this.PictureFormat);
[ Mr. Rejn @ 11.04.2007. 19:09 ] @
Citat:
miodrag77: probaj ovim linijama da zamenis mesta

Binding imageBinding = new Binding("Image", dt, "FOTO",true);
imageBinding.Format += new ConvertEventHandler(this.PictureFormat);

Kako da im zamenim mesta, mislis da stavim drugu liniju ispred prve ili sta?