Scale image to fit picture box?

Posted on 2011-04-21
Last Modified: 2012-05-11
Hello expert, i am using visual studio 2008 picture box control to load images from our database.  The problem is some of the images are too large, to fit in the picturebox and since this application will be running on a touch screen computer, i dont want to use scrollbars.  I was wondering how i could size the images to fit in the picturebox?  The resolution doesnt have to be perfect, it would just be nice if the image wasnt getting cut off.  Any ideas?
Question by:tentavarious
    LVL 23

    Expert Comment

    Try setting PictureBox.SizeMode = PictureBoxSizeMode.Zoom.  The Height and Width must be set for it to work properly.
    LVL 51

    Accepted Solution

    LVL 12

    Expert Comment

    by:Mohamed Abowarda
    Change the picture box size mode to stretch image:
    pictureBox.SizeMode = PictureBoxSizeMode.StretchImage

    Open in new window

    Replace pictureBox to your picture box name.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now