0
votes

I've got a pitiful problem with window desing in winforms. So the document outline is like this:

  • TableLayoutPanel
    • groupbox1
    • panel1
    • panel2 (AutoSize = true, Dock = Fill, AutoScroll = true)
      • groupbox2 (AutoSize = true, Dock = Fill)
        • picturebox (Dock = Fill, there is no AutoSize property for that control)

The important is panel2 and what is in it. I load an image to the picture box and I want to make it resizing (if table layout panel is to big for window I want scroll to appear). What do I do wrong? Now the picturebox has always size 0,0 so image is not visible.

1

1 Answers

1
votes

First thing in PictureBox there is property SizeMode where you can set the mode to AutoSize.

pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;

Second thing when you set the control's Dock property to fill than it wont resize as per client control. Indirectly the size of the control will be set to its parent client area size. So, you should remove Dock property of both control PictureBox and GroupBox. because the AutoScroll bar property you have enabled is in Panel2. When the image is resized the GroupBox also should be resized.