Home All Groups Group Topic Archive Search About
Author
12 Oct 2005 8:06 PM
Ron
I have bunch of pictures that I load and all are different sizes.  Is there
a way to resize the picture box to the size of the picture?

Thanks

Author
12 Oct 2005 8:29 PM
Mike L
"Ron" <pleasespamme@spam.com> wrote:
> I have bunch of pictures that I load and all are different sizes.  Is
there
> a way to resize the picture box to the size of the picture?

In the properties of the picture box, set the AutoSize property to True. Or,
if you want to do it by code,

Picture1.AutoSize = True
Author
12 Oct 2005 8:33 PM
Rick Rothstein [MVP - Visual Basic]
> I have bunch of pictures that I load and all are different
> sizes.  Is there a way to resize the picture box to the
> size of the picture?

This code should do what you want and handle all possible
combinations of the BorderStyle and Appearance properties...

With Picture1
  .Width = .ScaleX(.Picture.Width, vbHimetric, .ScaleMode) + _
           .ScaleX(2 * (1 + .Appearance) * .BorderStyle * _
           Screen.TwipsPerPixelX, vbTwips, .ScaleMode)
  .Height = .ScaleY(.Picture.Height, vbHimetric, .ScaleMode) + _
            .ScaleY(2 * (1 + .Appearance) * .BorderStyle * _
            Screen.TwipsPerPixelY, vbTwips, .ScaleMode)
End With

Rick
Author
12 Oct 2005 8:45 PM
Rick Rothstein [MVP - Visual Basic]
ROTFLMAO... I have no idea where my head was when I posted this
"solution".

AutoSize... How could I have not remembered of that?

Rick



"Rick Rothstein [MVP - Visual Basic]"
<rickNOSPAMnews@NOSPAMcomcast.net> wrote in message
Show quoteHide quote
news:u0zPzw2zFHA.720@TK2MSFTNGP15.phx.gbl...
> > I have bunch of pictures that I load and all are different
> > sizes.  Is there a way to resize the picture box to the
> > size of the picture?
>
> This code should do what you want and handle all possible
> combinations of the BorderStyle and Appearance properties...
>
> With Picture1
>   .Width = .ScaleX(.Picture.Width, vbHimetric, .ScaleMode) + _
>            .ScaleX(2 * (1 + .Appearance) * .BorderStyle * _
>            Screen.TwipsPerPixelX, vbTwips, .ScaleMode)
>   .Height = .ScaleY(.Picture.Height, vbHimetric, .ScaleMode) + _
>             .ScaleY(2 * (1 + .Appearance) * .BorderStyle * _
>             Screen.TwipsPerPixelY, vbTwips, .ScaleMode)
> End With
>
> Rick
>
>
Author
12 Oct 2005 9:05 PM
Tom Esh
On Wed, 12 Oct 2005 16:45:24 -0400, "Rick Rothstein [MVP - Visual
Basic]" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:

>ROTFLMAO... I have no idea where my head was when I posted this
>"solution".
>
>AutoSize... How could I have not remembered of that?

Maybe because (like me) you been doing this since before the picbox
had that prop <g> ?


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
Author
12 Oct 2005 10:34 PM
MikeD
"Tom Esh" <tjeshGibber***@suscom.net> wrote in message
news:ehuqk1lhtgh9pdil08qkbor9vocdgplcm5@4ax.com...
> On Wed, 12 Oct 2005 16:45:24 -0400, "Rick Rothstein [MVP - Visual
> Basic]" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:
>
>>ROTFLMAO... I have no idea where my head was when I posted this
>>"solution".
>>
>>AutoSize... How could I have not remembered of that?
>
> Maybe because (like me) you been doing this since before the picbox
> had that prop <g> ?


I admit guilt too. I did a double-take when I just opened VB, added a
picbox, and checked its properties. I thought only an Image control could
resize based on the graphic (via a property setting).

Just goes to show there's always more to learn.

--
Mike
Microsoft MVP Visual Basic
Author
12 Oct 2005 10:43 PM
Bob Butler
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:uA7TX03zFHA.1640@TK2MSFTNGP12.phx.gbl
> "Tom Esh" <tjeshGibber***@suscom.net> wrote in message
> news:ehuqk1lhtgh9pdil08qkbor9vocdgplcm5@4ax.com...
>> On Wed, 12 Oct 2005 16:45:24 -0400, "Rick Rothstein [MVP - Visual
>> Basic]" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:
>>
>>> ROTFLMAO... I have no idea where my head was when I posted this
>>> "solution".
>>>
>>> AutoSize... How could I have not remembered of that?
>>
>> Maybe because (like me) you been doing this since before the picbox
>> had that prop <g> ?
>
> I admit guilt too. I did a double-take when I just opened VB, added a
> picbox, and checked its properties. I thought only an Image control
> could resize based on the graphic (via a property setting).

Image controls have the stretch property which make the image adjust to
match the control.  The picturebox has the autosize which makes the control
adjust to match the picture.  Why they both don't have a single 'autosize'
property with 0=none, 1=image to control, 2=control to image is beyond me.
A little consistency woudl be nice!

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
12 Oct 2005 10:53 PM
Tom Esh
On Wed, 12 Oct 2005 15:43:20 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

>A little consistency woudl be nice!

Too late. <g>


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
Author
12 Oct 2005 8:34 PM
Mike Williams
"Ron" <pleasespamme@spam.com> wrote in message
news:OwU4dk2zFHA.3300@TK2MSFTNGP15.phx.gbl...

>I have bunch of pictures that I load and all are different sizes.
>Is there a way to resize the picture box to the size of the picture?

Yes.

Mike
Author
12 Oct 2005 10:41 PM
MikeD
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message
news:dijs0h$48o$1@news8.svr.pol.co.uk...
> "Ron" <pleasespamme@spam.com> wrote in message
> news:OwU4dk2zFHA.3300@TK2MSFTNGP15.phx.gbl...
>
>>I have bunch of pictures that I load and all are different sizes.
>>Is there a way to resize the picture box to the size of the picture?
>
> Yes.


Now THAT was helpful! I nominate you for posting the best answer of the
month, even the entire year! Hell, you should be an MVP based on that
answer!

Sarcasm aside, I suppose you did answer the question. But sheesh.  You could
have been more helpful than that. Why did you even bother to reply?

--
Mike
Microsoft MVP Visual Basic
Author
13 Oct 2005 7:54 AM
Mike Williams
"MikeD" <nob***@nowhere.edu> wrote in message
news:eVzXV43zFHA.3180@TK2MSFTNGP14.phx.gbl...

> Sarcasm aside, I suppose you did answer the question.
> But sheesh.  You could have been more helpful than that.
> Why did you even bother to reply?

Often I write extremely long and replies, so I decided it was time for a
short one :-)
Actually, the question had already been answered and I was already on my
fourth can of Bud!

Mike
Author
13 Oct 2005 1:04 PM
Bob Butler
"Mike Williams" <M***@WhiskyandCoke.com> wrote in message
news:dil3tc$398$1@newsg4.svr.pol.co.uk
> my fourth can of Bud!

Bud? CAN?
Philistine! <g>

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
12 Oct 2005 8:38 PM
Ken Halter
"Ron" <pleasespamme@spam.com> wrote in message
news:OwU4dk2zFHA.3300@TK2MSFTNGP15.phx.gbl...
>I have bunch of pictures that I load and all are different sizes.  Is there
>a way to resize the picture box to the size of the picture?
>
> Thanks

Picturebox controls have an AutoResize property. Problem is, there's really
no control. If the picture's very large or very small, you'll have a hard
time getting things to look right.

If you trade the picturebox for an Image control (and set the border style
to Fixed Single to make it look like a picturebox), you gain a bit of
control over how things look and what size they are.

Resize Image?
http://groups.google.com.my/group/microsoft.public.vb.controls/browse_frm/thread/de3561568c4e26b8

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..