On button click, I want the picturebox to load an image.

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 45
Reputation: papuccino1 is an unknown quantity at this point 
Solved Threads: 1
papuccino1's Avatar
papuccino1 papuccino1 is offline Offline
Light Poster

On button click, I want the picturebox to load an image.

 
0
  #1
Nov 1st, 2008
A THOUSAND apologies if this question has been asked time and time again.

Google gave no results and Jeeves is retired so I come looking for help in the best programming forum around.

  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. pictureBox1.ImageLocation=???????????
  4. }

My question is fairly simple, what do I put at the other side of the "="?
My very first baby boy, coming December 2008. :D
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: On button click, I want the picturebox to load an image.

 
0
  #2
Nov 2nd, 2008
either a path or a url to the image file
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: On button click, I want the picturebox to load an image.

 
0
  #3
Nov 2nd, 2008
Image.FromFile(/*put your path here*/);
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,957
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 283
ddanbe's Avatar
ddanbe ddanbe is online now Online
Posting Virtuoso

Re: On button click, I want the picturebox to load an image.

 
0
  #4
Nov 2nd, 2008
Or you might open a filedialog in your buttonclick like this :

  1. OpenFileDialog dlg = new OpenFileDialog();
  2. dlg.Title = "Open bitmap or jpeg.";
  3. //dlg.Filter = "jpg files (*.jpg);*.jpg;*.* | bmp files (*.bmp); *.bmp";
  4.  
  5. if (dlg.ShowDialog() == DialogResult.OK)
  6. {
  7. this.fotoPictureBox.Image = new Bitmap(dlg.OpenFile());
  8. }
  9. dlg.Dispose();
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 58
Reputation: vckicks is an unknown quantity at this point 
Solved Threads: 9
vckicks vckicks is offline Offline
Junior Poster in Training

Re: On button click, I want the picturebox to load an image.

 
0
  #5
Nov 3rd, 2008
Several ways to do it, here is an article on loading image files. Just make sure to dispose of new objects properly depending on how you load the images
Visual C# Kicks - Free C# code resources and articles.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC