How to Stretch Background Picture?

Posted on 2005-04-15
Last Modified: 2008-02-01
I use a PictureBox as a container for one 'panel' on an MDI form.  The graphic (jpg) that I want to use as the backround picture is shorter than the height of the panel.  Thus when I load the graphic it only shows a background for the top 3/4 of the picturebox and then stops.  Are there any options to set which will 'stretch' the graphic to fit the entire area of the picture box.

When I have preiously placed pictures in an image control on the form there was s 'stretch' property to accomodate this.  There is no corresponding property on a picturebox control.

Any suggestions?
Question by:mlcktmguy
    1 Comment
    LVL 38

    Accepted Solution

    Private Sub Picture1_Paint()
        Picture1.PaintPicture LoadPicture("C:\temp\1.jpg"), 0, 0, Picture1.Width, Picture1.Height
    End Sub

    If you want to store the picture in the picturebox at design time, you can load it into a second picture box, set the visible to false on the second and write the paint procedure like this:

    Private Sub Picture1_Paint()
        Picture1.PaintPicture Picture2.Picture, 0, 0, Picture1.Width, Picture1.Height
    End Sub

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    728 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

    15 Experts available now in Live!

    Get 1:1 Help Now