Loading an image

  • Thread starter Thread starter Xarky
  • Start date Start date
X

Xarky

Hi,
I have a browse button, where I am selecting an image. How can I
load it into a PitctureBox?


Thanks in Advance
 
Xarky,

I assume you mean you have selected a file from the textbox. If you
want an image, you can pass the filename to the constructor of the Bitmap
class, and pass that to your PictureBox.

Hope this helps.
 
If you have browser button which shows the file dialog --> use
Image.FromFile (string filename) to load it into the PictureBox.

OpenFileDialog dlg = new OpenFileDialog();

if (dlg.ShowDialog (this) == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile (dlg.FileName);
}

Regards,
Peter Jausovec
(http://blog.jausovec.net)


Xarky,

I assume you mean you have selected a file from the textbox. If you
want an image, you can pass the filename to the constructor of the Bitmap
class, and pass that to your PictureBox.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Xarky said:
Hi,
I have a browse button, where I am selecting an image. How can I
load it into a PitctureBox?


Thanks in Advance
 
Hi,

I assume that the button create a OpenFileDialog where the user can browse
for the file, if so you get the result from it using the FileName property,
if so all you have to do is create a Bitmap from that file and assign it to
the picturebox

you will have to take care of the size of the image though.

Cheers,
 
Back
Top