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
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.
Re: Help Newbie on Loading Picture
Quote:
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