Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

  • 2 odgovora
  • 2.356 pregleda

Najnovija ↓

Jpeg iz baze u PictureBox-u 11.04.2007. u 13:51 · pre 238 meseci #1
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);
Potpis
Ag + Na -> Xe
Re: Jpeg iz baze u PictureBox-u 11.04.2007. u 15:09 · pre 238 meseci #2
probaj ovim linijama da zamenis mesta

Binding imageBinding = new Binding("Image", dt, "FOTO",true);
imageBinding.Format += new ConvertEventHandler(this.PictureFormat);
Re: Jpeg iz baze u PictureBox-u 11.04.2007. u 20:09 · pre 238 meseci #3
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?
Potpis
Ag + Na -> Xe
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme