Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Jpeg iz baze u PictureBox-u

[es] :: .NET :: Jpeg iz baze u PictureBox-u

[ Pregleda: 1859 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Mr. Rejn
Deki Karamatijević
Sremčica

Član broj: 2514
Poruke: 515
212.200.220.*



+4 Profil

icon Jpeg iz baze u PictureBox-u11.04.2007. u 12:51 - pre 207 meseci
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);
Ag + Na -> Xe
 
Odgovor na temu

miodrag77
Miodrag Dragic
NS

Član broj: 43159
Poruke: 59
*.ADSL.neobee.net.



Profil

icon Re: Jpeg iz baze u PictureBox-u11.04.2007. u 14:09 - pre 207 meseci
probaj ovim linijama da zamenis mesta

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

Mr. Rejn
Deki Karamatijević
Sremčica

Član broj: 2514
Poruke: 515
212.200.220.*



+4 Profil

icon Re: Jpeg iz baze u PictureBox-u11.04.2007. u 19:09 - pre 207 meseci
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?
Ag + Na -> Xe
 
Odgovor na temu

[es] :: .NET :: Jpeg iz baze u PictureBox-u

[ Pregleda: 1859 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.