I have a form with a Panel which covers the entire form and serves as a scrollable area for the child controls. Basically I put PictureBox controls into the panel, 3-4 in a column. The problem is when the number of PictureBoxe is high, I cannot place them all into the Panel, it just refuses to set PictureBox.Left property when I set it higher than about 32470 px, i.e. when I set it to 32570 it is being set down to 32470.
Is there a limit on the width of the scrollable parent then?
The code I use looks like this:
for (int a...)
{
PictureBox pic = new PictureBox
{
Parent = panel1,
Width = 150,
Height = 150,
Left = x,
Top = y
};
}
xandyare calculated inside the loop to put the PictureBoxes in rows/columns.
I am surprised that this is happening at that value. This is a limitation of Windows itself. It puts all of its messages in a 16 bit WORD, so the maximum value for any X or Y position should be 32767. You could always try to add another panel whenever this max is hit, and then you would be referencing from 0 in the new panel again?