I have a windows form with the following basic structure....
Picturebox nested on a Panel nested on a ToolStripContainer.Content
Panel.
I've set the picturebox.sizemode to AutoSize and the Panel.autoscroll property to true.
Next I generate a BMP which exceeds the X and Y bounds of the form and place it as the image on the picturebox.
When I do this the vertical scrollbar shows up but the horizontal scrollbar is missing? What am I missing here??
using System;
using System.Collections.Generic
;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace Project1
{
/* DEMO class for exploring behavior of scrollbars,
* dockstyles, and anchorstyles.
*/
class clsGUI : Form
{
ToolStripContainer tscMain = new ToolStripContainer();
ToolStrip tsTop = new ToolStrip();
ToolStrip tsBottom = new ToolStrip();
Panel pnlMain = new Panel();
PictureBox pboxMain = new PictureBox();
public clsGUI()
{
//tool strip container
tscMain.Anchor = AnchorStyles.Top & AnchorStyles.Left;
tscMain.Dock = DockStyle.Fill;
//panel nested on the toolstrip container contentpanel
pnlMain.Anchor = AnchorStyles.Top & AnchorStyles.Left;
pnlMain.Dock = DockStyle.Fill;
pnlMain.AutoScroll = true;
pnlMain.BackColor = Color.DarkGray;
tscMain.ContentPanel.Contr
ols.Add(pn
lMain);
//picturebox nested on pnlMain
pboxMain.Anchor = AnchorStyles.Top & AnchorStyles.Left;
pboxMain.Dock = DockStyle.Top;
pboxMain.SizeMode = PictureBoxSizeMode.AutoSiz
e;
pnlMain.Controls.Add(pboxM
ain);
ToolStripButton tsbtn1=new ToolStripButton("push me",null,loadImage);
tsTop.Items.Add(tsbtn1);
tscMain.TopToolStripPanel.
Controls.A
dd(tsTop);
tscMain.BottomToolStripPan
el.Control
s.Add(tsBo
ttom);
base.Controls.Add(tscMain)
;
}
private void InitializeComponent()
{
base.SuspendLayout();
base.Width = 500;
base.Height = 500;
base.CenterToScreen();
this.ResumeLayout(false);
}
private void loadImage(object sender, EventArgs e)
{
Bitmap objBMP = new Bitmap(1000, 1000);
MemoryStream ms=new MemoryStream();
Graphics GFX=Graphics.FromImage(obj
BMP);
Pen objPen = new Pen(Color.Red);
objPen.Width = 10;
GFX.DrawEllipse(objPen,0,0
,1000,1000
);
objBMP.Save(ms,ImageFormat
.Bmp);
pboxMain.Image = Image.FromStream(ms);
}
}
}