Reputation: 5299
On my form i have a PictureBox inside Panel.
I set:
MyPanel.AutoScroll = true
MyPictureBox.SizeMode = AutoSize
After i add image into PictureBox:
MyPictureBox.Image = Image.FromFile(path);
But when i open form i don't see any scrollbars inside.
What can be wrong?
Upvotes: 2
Views: 5412
Reputation: 898
Tips:
MyPictureBox
is inside MyPanel
, in other words, MyPanel
contains MyPictureBox
.MyPictureBox
significantly smaller than its container MyPanel
. Due to AutoSize
, it will fill the entire space provided by the container during runtime.MyPictureBox
has property Anchor
set to Top, Left
but NOT Top, Left, Bottom, Right
.Upvotes: 1
Reputation: 114
You have to probably set height and width of PictureBox and set AutoScroll property of Panel to true.
Panel MyPanel = new Panel();
PictureBox pictureBox1 = new PictureBox();
Image image = Image.FromFile("image.png");
pictureBox1.Image = image;
pictureBox1.Height = image.Height;
pictureBox1.Width = image.Width;
MyPanel.Controls.Add(pictureBox1);
MyPanel.AutoScroll = true;
this.Controls.Add(MyPanel);
Upvotes: 1