Hi guys!

I have a form with a width of 15420. This form contains a Picturebox, which width is 865, but the problem is both window and Picturebox have almost the same width. Somehow they have a different scale.

I tried modifying the Scalemode property, but nothing changes.

What I need is the Picturebox to addapt its size every time the form is resized, but with these different scales I don't know how to do that.

Any ideas?

Who is Participating?
rettiseertConnect With a Mentor Commented:

Check that all your controls have the scalemode

Your picturebox may be inside another picturebox or inside a frame with a different scalemode than the one in the form
pvg1975Author Commented:
Other controls as Shape, Texbox, etc have the right scale (as the form width): 14564, 8334, 2245, etc but the Pictureboxes!
Your form uses a unit called twip, where the picturebox is using the pixel unit. Usually 15 twip = 1 pixel.
There are several ways to solve this problem

- You can set the picturebox scalemode = twip so the unit used by the picturebox is the same as the one used by the form.
This sollution is simple in theory but if you have coded other functions that considers the picturebox unit is pixel you'll have to modify these functions. This mission may get you into a lot of mess, so if that is your situation consider the next sollution.

- You can set the form scalemode = pixel
to read the width property of the form:
    Dim PixWidth as integer
    PixWidth = Me.ScaleWidth

to set the form's width:
    Me.Width = 100 * Screen.TwipsPerPixelX ' this is equevelant to 100 pixels

NOTE: Parent scalemode property overrides child scalemode property
pvg1975Author Commented:
Thanks guys!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.