|
-
May 6th, 2013, 12:55 AM
#1
Thread Starter
New Member
Help Newbie on Loading Picture
Hi Guys
First post here Im sure this is something simple but I cant get it to work
I have a Picturebox on my form with a blank picture in it
I have a button which when clicked opens the opendialog picture box so I can select a jpg file it then loads into the picturebox a picture using the following code
PictureBox5.Image = Image.FromFile(openFileDialog1.FileName)
This all works fine except i cant see all the picture as it needs fitting to the size of the picturebox
I tried the following code to no avail
PictureBox5.BackgroundImageLayout = ImageLayout.Stretch
any ideas where i have gone wrong? is there another way to achieve what I am trying to do?
Thanks
Mark
-
May 6th, 2013, 01:26 AM
#2
Re: Help Newbie on Loading Picture
The BackgroundImageLayout is irrelevant because you're not setting the BackgroundImage. What you want is the SizeMode property. Most likely you'll want to set it to Zoom, which displays the Image as large as possible while maintaining the original aspect ratio.
-
May 6th, 2013, 02:14 AM
#3
Thread Starter
New Member
Re: Help Newbie on Loading Picture
 Originally Posted by jmcilhinney
The BackgroundImageLayout is irrelevant because you're not setting the BackgroundImage. What you want is the SizeMode property. Most likely you'll want to set it to Zoom, which displays the Image as large as possible while maintaining the original aspect ratio.
thank you Jmcilhinney
PictureBox5.SizeMode = PictureBoxSizeMode.StretchImage did exactly what i wanted
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|