Hi,

I have a panel on a form and am displaying a picturebox on that panel.

I have set the Panel Autoscroll to true.

Even when I manually make the panel smaller than the picturebox, no scrollbars are shown, why is this?

Here is the code I am using to display the picturebox:-

void MainFormLoad(object sender, EventArgs e)
		{
			
PictureBox pb = new PictureBox();

pb.Parent = panel1;

pb.Location = new Point(20, 18);

pb.Size = new Size(75, 75);

pb.BorderStyle = BorderStyle.Fixed3D;

pb.ImageLocation = "http://farm5.static.flickr.com/.jpg";

pb.Cursor = System.Windows.Forms.Cursors.Hand;

this.Controls.Add(pb);

pb.BringToFront();

pb.Click += delegate(object s, EventArgs e2)
{
System.Diagnostics.Process.Start("http://www.flickr.com/photos/");
};
}

As you can see, the panel has been set as the parent of the picturebox.

I have a feeling that it is possibly the pb.BringToFront that might be the issue but if I remove that the picturebox appears behind the panel.

Regards..,

MT ;)

You should add it to the Panel and not the Form. I mean you should use panel1.Controls.Add(pb); instead of this.Controls.Add() Thanks

You should add it to the Panel and not the Form. I mean you should use panel1.Controls.Add(pb); instead of this.Controls.Add() Thanks

Thank you Farooq, it looks such a simple step now I know.

Kind regards..,

MT :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.