Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / April 2007

Tip: Looking for answers? Try searching our database.

Databinding PictureBox Image in JPEG format

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeronimo Bertran - 19 Sep 2006 02:27 GMT
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

Jeronimo Bertran
Linda Liu [MSFT] - 19 Sep 2006 13:57 GMT
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.
Linda Liu [MSFT] - 21 Sep 2006 12:57 GMT
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
billy bob - 06 Apr 2007 07:21 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.