Problem with AutoScroll and PictureBox [C#]

F

Fernando Cacciola

Hi all,

In C#, I had a Form with a PictureBox
I use the picture box just the paint a vector drawing (using paths).
The idea is to resize the Image according to the drawing extents.
What I expected was that the parent form added scrollbars (AutoScroll is
true)
(that's the reason why using a PicutureBox insted of drawing directly on the
Form client area)

TIA

Fernando Cacciola
 
H

Herfried K. Wagner [MVP]

* "Fernando Cacciola said:
In C#, I had a Form with a PictureBox
I use the picture box just the paint a vector drawing (using paths).
The idea is to resize the Image according to the drawing extents.
What I expected was that the parent form added scrollbars (AutoScroll is
true)
(that's the reason why using a PicutureBox insted of drawing directly on the
Form client area)

What's the problem? Are you sure you made the picturebox larger than
the form's client area?
 
F

Fernando Cacciola

Herfried K. Wagner said:
What's the problem? Are you sure you made the picturebox larger than
the form's client area?
I think so:

// mW, mH is the size of the vector darwing
// mSX, mSY are zoom factors

Image lImage = new Bitmap(mW*mSX, mH*mSY, PixelFormat.Format24bppRgb);

// Canvas is the name of the PictureBox
Canvas.Image = lImage ;

// This is how In set the size of the PictureBox
Canvas.Size = new Size(lImage.Width,lImage.Height);

// Draw on it
Graphics lG = Graphics.FromImage(lImage);
lG.ScaleTransform(mSX,mSY);
Render(lG); // Draw on the image

When I run the App containing this code, I can increaze the zoom factor and
I can see the image enlaring until if goes well beyond the Form client area.

The Form AutoScroll is set to true, but the scoll bars never appears.

TIA

Fernando Cacciola
SciSoft
 
H

Herfried K. Wagner [MVP]

* "Fernando Cacciola said:
When I run the App containing this code, I can increaze the zoom factor and
I can see the image enlaring until if goes well beyond the Form client area.

The Form AutoScroll is set to true, but the scoll bars never appears.

Place the picturebox inside a panel with 'AutoScroll' set to 'True' and
try again.
 
F

Fernando Cacciola

Herfried K. Wagner said:
Place the picturebox inside a panel with 'AutoScroll' set to 'True' and
try again.

Still doesn't work.

Could I be doing something wrong with the other properties (Anchors,
AutoSize, etc)?

Fernando Cacciola
SciSoft
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top