Hi there,

I need to show an image centered on a form. That's easy,
use a Picturebox... problem is the images may be
different sizes, and I need to resize to show the image
with the correct aspect ratio (ie: height vs width)...
sometimes the image will be too big to fit on the form so
then I'd like scrollbars... I need like a "shrink/stretch
to fit" method which understands the aspect ratio bit....

Is it me or is the picturebox control pretty useless...?

Can anybody suggest a way of achieving what I want with
standard .Net controls... or am I going to have to
subclass the picturebox (or make my own version)...?

Any help appreciated...

Cheers

Re: Decent image control by Jason

Jason
Tue Nov 25 21:59:42 CST 2003


Could you put the PictureBox control inside a Panel control? The panel
should allow you to scroll when the controls inside it are larger than its
client area.

Jason Dorie



"Bob" <bob@nospam.com> wrote in message
news:%23NTiK08sDHA.3416@tk2msftngp13.phx.gbl...
> Hi there,
>
> I need to show an image centered on a form. That's easy,
> use a Picturebox... problem is the images may be
> different sizes, and I need to resize to show the image
> with the correct aspect ratio (ie: height vs width)...
> sometimes the image will be too big to fit on the form so
> then I'd like scrollbars... I need like a "shrink/stretch
> to fit" method which understands the aspect ratio bit....
>
> Is it me or is the picturebox control pretty useless...?
>
> Can anybody suggest a way of achieving what I want with
> standard .Net controls... or am I going to have to
> subclass the picturebox (or make my own version)...?
>
> Any help appreciated...
>
> Cheers



Re: Decent image control by Justin

Justin
Wed Nov 26 03:43:40 CST 2003

Michael Gold has an article on C# Corner showing a good implementation of a
zoomable, scrollable picturebox.

http://www.c-sharpcorner.com/Graphics/ScrollablePictureBox.asp

We used a slight modification on his example for the export image
functionality of GDI+ Architect with much success.

--

Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com


"Bob" <bob@nospam.com> wrote in message
news:%23NTiK08sDHA.3416@tk2msftngp13.phx.gbl...
> Hi there,
>
> I need to show an image centered on a form. That's easy,
> use a Picturebox... problem is the images may be
> different sizes, and I need to resize to show the image
> with the correct aspect ratio (ie: height vs width)...
> sometimes the image will be too big to fit on the form so
> then I'd like scrollbars... I need like a "shrink/stretch
> to fit" method which understands the aspect ratio bit....
>
> Is it me or is the picturebox control pretty useless...?
>
> Can anybody suggest a way of achieving what I want with
> standard .Net controls... or am I going to have to
> subclass the picturebox (or make my own version)...?
>
> Any help appreciated...
>
> Cheers
>
>
>
>



Re: Decent image control by hirf-spam-me-here

hirf-spam-me-here
Wed Nov 26 04:18:05 CST 2003

* "Bob" <bob@nospam.com> scripsit:
> I need to show an image centered on a form. That's easy,
> use a Picturebox... problem is the images may be
> different sizes, and I need to resize to show the image
> with the correct aspect ratio (ie: height vs width)...
> sometimes the image will be too big to fit on the form so
> then I'd like scrollbars... I need like a "shrink/stretch
> to fit" method which understands the aspect ratio bit....
>
> Is it me or is the picturebox control pretty useless...?
>
> Can anybody suggest a way of achieving what I want with
> standard .Net controls... or am I going to have to
> subclass the picturebox (or make my own version)...?

You can add the picturebox control to a panel control with 'AutoScroll'
= 'True'. If the pixturebox gets larger than the panel, scrollbars will
be showed. The picturebox provides a 'SizeMode' property which allows
you to specify the size mode.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Re: Decent image control by Bob

Bob
Wed Nov 26 05:50:53 CST 2003

The GDI+ FAQ has an article on how to display an image in its original
aspect ratio centered on a form or control. It would be easy to adapt this
to a control that would do what you need.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Bob" <bob@nospam.com> wrote in message
news:%23NTiK08sDHA.3416@tk2msftngp13.phx.gbl...
> Hi there,
>
> I need to show an image centered on a form. That's easy,
> use a Picturebox... problem is the images may be
> different sizes, and I need to resize to show the image
> with the correct aspect ratio (ie: height vs width)...
> sometimes the image will be too big to fit on the form so
> then I'd like scrollbars... I need like a "shrink/stretch
> to fit" method which understands the aspect ratio bit....
>
> Is it me or is the picturebox control pretty useless...?
>
> Can anybody suggest a way of achieving what I want with
> standard .Net controls... or am I going to have to
> subclass the picturebox (or make my own version)...?
>
> Any help appreciated...
>
> Cheers
>
>
>
>