7

I've 2 buttons, 1 PictureBox and 1 Panel. PictureBox's inside of the Panel and Panel's AutoScroll property is set to "true". Also PictureBox Dock property is set to "Fill".

  1. Button draws a Rectangle into the pictureBox, 2. one makes it bigger whose size is bigger than the pictureBox itself. So, I need pictureBox to be scrollable.

How can I make it? Any example for this thread?

My Best Regards...

Important: Please don't give advise using existing files! I'm not using them.

Stecya
  • 22,896
  • 10
  • 72
  • 102
unnamed
  • 840
  • 9
  • 26
  • 38

2 Answers2

6

Disclaimer: Not tested.
1- Set your panel's AutoScroll property to true:

this.panel1.AutoScroll = true;  

2- Set SizeMode property of your picturebox to AutoSize:

this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;  

That should do the trick.
If you still have problems, there are some workaround mentioned in the following pages:
http://forums.techarena.in/software-development/1305463.htm
http://www.eggheadcafe.com/community/aspnet/2/10020769/picturebox.aspx If you

Kamyar
  • 18,639
  • 9
  • 97
  • 171
  • What about the `Dock` property of the pictureBox? Should it stay on `Fill` or be set to `None`? – Oliver May 24 '11 at 11:48
  • Haven't tested and I'm very much in doubt the first solution I have mentioned would work. But there are some workarounds mentioned in the posts I have addressed. – Kamyar May 24 '11 at 11:52
5

To do that, you need to change the PictureBox's Dock to None, then set the size yourself.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964