all groups > dotnet windows forms databinding > september 2006 >
You're in the

dotnet windows forms databinding

group:

Databinding PictureBox Image in JPEG format


Databinding PictureBox Image in JPEG format Jeronimo Bertran
9/18/2006 6:27:25 PM
dotnet windows forms databinding: Hi,

I wrote an applicartion that uses databinding to retrieve and store images
from a database to a PictureBox. It seems that the databinding is storing
the images in BMP format and I need to store them using JPG format.... I
know that from the PictureBox I can save to a byte[] in JPG format using
the following:

MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] imageBytes = ms.ToArray();

But how can I make the DataBindings use this format?

Thanks

RE: Databinding PictureBox Image in JPEG format v-lliu NO[at]SPAM online.microsoft.com
9/19/2006 12:57:51 PM
Hi Jeronimo,

When we bind a data source to a property of a control, we add a Binding
object to the DataBindings property of the control. There's an event called
Format in the binding object, which occurs when the property of a control
is bound to a data value.

We could subscribe and handle this event to store the image in the
picturebox in JPG format.

The following is a sample on how to subscribe and handle the Format event
of the binding object.

public Form1()
{
this.pictureBox1.DataBindings[0].Format += new
ConvertEventHandler(Form1_Format);
}

void Form1_Format(object sender, ConvertEventArgs e)
{
// add the code to store the image in picturebox in JPG format
.....
}

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Databinding PictureBox Image in JPEG format v-lliu NO[at]SPAM online.microsoft.com
9/21/2006 12:00:00 AM
Hi Jeronimo,

How about the problem now?

If the problem is not solved or you need our further assistance, please
feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!


Sincerely,
Linda Liu
Microsoft Online Community Support

RE: Databinding PictureBox Image in JPEG format billy bob
4/5/2007 11:21:51 PM


hello...well...i need help from u...actually i want to store image in
database(using access)...n then bind it with vb...n when entered GRNO.
in a textbox...the image must be displayed in the image control...plz
help me out...its urgent...tell me abt of what n where to set properties
for the controls n all required instruction...regarding database n vb.

AddThis Social Bookmark Button