Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use VS2015/C# on Win10 to test Panel control:

Add 50 PictureBox controls into panel1:

Image img = Image.FromFile(Application.StartupPath + @"\1.png"); //any image

panel1.AutoScroll = true;
panel1.Height = 500;

for (int i = 0; i < 50; i++)
{
PictureBox pb = new PictureBox();
pb.Left = i*10;
pb.Top = i * (img.Height + 10);
pb.SizeMode = PictureBoxSizeMode.AutoSize;
pb.Image = img;
toolTip1.SetToolTip(pb, i.ToString()+": "+pb.Top.ToString());
panel1.Controls.Add(pb);
}

If the 'Top' of a picture box is less than 32767, the picture box can be placed in right position. But if the 'Top' of a picture box is greater than 32767, the picture box can not be placed in right position, it will be placed at the bottom of the panel. In an another word, the maximum scrollable height of Panel control is like 32767.

I want all picture box in wanted position in panel. Is any method to enlarge panel scrollable size?

What I have tried:

This issue is exist on Win7/8/10, but no found in WinXP. It is no relation with VS versions and .NET framework versions, just in relation with Windows versions.
Posted
Updated 20-Feb-17 0:56am
Comments
Dharmesh .S. Patil 17-Feb-17 4:32am    
Try to use FlowLayoutPanel control to add picturebox instead of panel it automatic handle the position of picturebox..
Ralf Meier 17-Feb-17 7:21am    
I would build my own customized Panel which has the behaviour I want to have.
In this Panel I would not place all of your Pictures - only those which can be seen and one more at the Top (negative coordinates) and one more at the Bottom (outside the Panel).
Now I would build up a special Scroll-Function which only works with this Controls and assign them (if needed) new Pictures.
Philippe Mori 18-Feb-17 10:03am    
As a solution, it would worth 5 points...
Ralf Meier 18-Feb-17 13:59pm    
Do you think that I should post that as Solution ?
In my opinion this is only an advice ... or perhaps my way how to solve this ...
Maciej Los 20-Feb-17 6:40am    
This is a solutioin - for sure - even if it's your opinion (advice).

1 solution

I would build my own customized Panel which has the behaviour I want to have.
In this Panel I would not place all of your Pictures - only those which can be seen and one more at the Top (negative coordinates) and one more at the Bottom (outside the Panel).
Now I would build up a special Scroll-Function which only works with this Controls and assign them (if needed) new Pictures.
 
Share this answer
 
Comments
Maciej Los 20-Feb-17 7:59am    
5ed!
Ralf Meier 20-Feb-17 8:42am    
Thank you, Maciej

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900