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 / March 2005

Tip: Looking for answers? Try searching our database.

Binding my Blob to a Picturebox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig Muckleston - 21 Mar 2005 22:52 GMT
I have a picturebox on my windows form. In this picturebox I'm going to
keeppictures of the employees. I can save the images to my access table
(tblPhoto.PhotoObject)

I want to be able to populate my picturebox with the image of the employee.
How can I go about binding it, or having the image show when I select an
employee?
Alexander Shirshov - 22 Mar 2005 04:47 GMT
Craig,

This method turns bytes received from the database into a Bitmap object
which you can display in a picture box like that:

pictureBox.Image = GetPhotos(bits);

 public System.Drawing.Bitmap GetPhoto(byte[] photoBits)
 {
  if (photoBits != null && photoBits.Length > 0)
  {
   using (MemoryStream stream = new MemoryStream(photoBits))
   {
    return new Bitmap(stream);
   }
  }
  else
  {
   // Return standard company approved photo :-)
   return null;
  }
 }

HTH,
Alexander

>I have a picturebox on my windows form. In this picturebox I'm going to
> keeppictures of the employees. I can save the images to my access table
[quoted text clipped - 4 lines]
> How can I go about binding it, or having the image show when I select an
> employee?

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.