Problem with AutoScroll and PictureBox [C#]

  • Thread starter Thread starter Fernando Cacciola
  • Start date Start date
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
 
* "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?
 
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
 
* "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.
 
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
 
Back
Top