VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,327 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,930 people online right now. Registration is fast and FREE... Join Now!





Load bitmap into PictureBox using OpenFileDialog

Use OpenFileDialog to browse to a bitmap image and load into a PictureBox.

Submitted By: Jayman
Actions:
Rating:
Views: 26,427

Language: VB.NET

Last Modified: October 17, 2006
Instructions: Drag a PictureBox from the toolbox to your form and set name to PictureBox1.

Snippet


  1. Dim OpenFileDialog1 As New OpenFileDialog
  2.  
  3.  
  4. With OpenFileDialog1
  5.     .CheckFileExists = True
  6.     .ShowReadOnly = False
  7.     .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
  8.     .FilterIndex = 2
  9.     If .ShowDialog = DialogResult.OK Then
  10.         ' Load the specified file into a PictureBox control.
  11.         PictureBox1.Image = Image.FromFile(.FileName)
  12.     End If
  13. End With

Copy & Paste


Comments


vinodachu 2008-03-01 01:25:35

thank you for that ,i need a solution to save image to acess database ,i think it has to convert to binary before saving to database pls show me coding for that..!!!!!!!!

jayman9 2008-03-01 16:03:00

You can find a tutorial on how to save an image in binary to an Access database "http://www.vbcode.com/Asp/showsn.asp?theID=13000"

arbalu 2008-07-26 00:51:45

more clear sample here http://developerskb.blogspot.com/2008/07/how-to-use-openfiledialog-for-uploading.html

zumanequeen 2008-08-25 11:02:20

hi im beginner here..why in my vs i didnt see the picturebox n openfiledialog to drag into my form.please help me...pls...tq

penyo 2009-02-24 04:15:18

where i was place this code?

Jayman 2009-02-24 19:44:51

Put the code in whichever event you want it to execute. Typically, the button click event is where you might find it.

sraptor 2009-05-04 08:50:27

Do you have the code to insert the picture to SQL database?

sandli28 2009-07-17 02:42:04

hi, its really veru useful.But will u plz also tell,how to retrieve the picture from access database into picturebox control on the form. Thanx, Regards, Sandeep

avinashbuliya 2009-10-10 02:50:37

thanks for help


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month