Results 1 to 3 of 3

Thread: Help Newbie on Loading Picture

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    14

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    14

    Re: Help Newbie on Loading Picture

    Quote Originally Posted by jmcilhinney View Post
    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
  •  



Click Here to Expand Forum to Full Width