Scrolling an Image in C#

Started by
6 comments, last by Hippokrates 20 years, 10 months ago
I am currently trying to write a small application using C#. Since I would like to display quite large images on my form I need to know: 1) Which control I have to use to display the image 2) How to add scrollbars to it 3) How to scroll the Image.
Im Anfang war die Tat...Faust
Advertisement
I''m fairly sure the PictureBox control should do what you want.


AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Well, I tried that one but could''nt convince it not to either scale the image to the size of the control or to scale the control to the size of the image...
Im Anfang war die Tat...Faust
Apologies for posting a "i dunno but.."

It may be that you need to make a new control that is a scrollable frame that holds a picture box. That is how I would do it using Swing, Qt, VB6, and Tk.

I don't use .Net though.

[edited by - flangazor on May 29, 2003 10:51:38 AM]
What flangazor says makes sense. Derive your own control from ScrollableControl and do the rendering of the image yourself in the OnPaint method.


AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

duh... set the SizeMode Property to what you want it to be like... stretching, autosize, whatever.
Another way is to put a Panel on the form, and set its autoscroll property to true, then put the picture box inside the panel and make the picture box as big as you want, and that should let you scroll around it if its size is set to bigger than the size of the Panel
Hey, it works ^^ (the trick with the panel did it).

BTW: does someone know how to do the same in C++?
Im Anfang war die Tat...Faust

This topic is closed to new replies.

Advertisement