I have a .NET PictureBox control added to a Windows.Forms.SplitterPanel. How do I do auto sizing the PictureBox to fit the SplitterPanel whenever I enlarge or shrink the SplitterPanel with mouse drag. Following is part of the code I have:
PictureBox ScreenPbx = new PictureBox();
ScreenPbx.Size = new System.Drawing.Size(480, 360);
ScreenPbx.SizeMode = PictureBoxSizeMode.StretchImage;
splitContainer.Panel.Controls.Add(ScreenPbx);
I have a picture fitted into the PictureBox with StretchImage option but the PictureBox is not “glued” to the splitContainer.panel so when I mouse drag to resize the panel, it doesn’t resize the PictureBox within it. Thank you in advance!
I’m assuming you are loading an image into the ScreenPbx control.
Instead of setting the size of the PictureBox, try docking it instead:
Alternatively, you could just set the anchors: