Here's one way to go about this that eliminates the need to move all the Buttons:
Structure:
0. all Panels have DockStyle.None
1. Panel: 'outmostPanel: has two Buttons, 'btnPrevious, 'btnNext positioned at the left and right sides of the 'outmostPanel vertically centered in the 'outmostPanel. Positioned on a Form where you want it.
Contains a Panel 'outerPanel
2. Panel: 'outerPanel: added to ControlCollection of 'outmostPanel, centered horizontally in 'outmostPanel, sized to fill 'outmostPanel vertically.
Contains a Panel" 'innerpanel
3. Panel: 'innerPanel: added to ControlCollection of 'outertPanel, centered horizontally,
4. Panels 'outerPanel and 'innerPanel use the same BackGroundColor. 'outmostPanel can have a contrasting BackColor, or the same as the other Panels, as you wish.
For testing purposes let's add a grid of Buttons to the 'innerPanel:
private const int RowOffset = 50;
private const int ColumnOffset = 120;
private const int Margin = 20;
private const int NRowsButtons = 6;
private const int NColsButtons = 8;
private Size buttonSize = new Size(40, 25);
private void MakeButtons()
{
innerPanel.Width = 1200;
for (int i = 0; i < NRowsButtons; i++)
{
for (int j = 0; j < NColsButtons; j++)
{
var btn = new Button
{
AutoSize = false,
Text = string.Format("{0}:{1}", i.ToString(), j.ToString()),
Size = buttonSize,
Location = new Point((j * ColumnOffset) + Margin, (i * RowOffset) + Margin)
};
btn.Click += btn_Click;
innerPanel.Controls.Add(btn);
}
}
}
private void btn_Click(object sender, EventArgs e)
{
Button buttonClicked = sender as Button;
}
The Button EventHandlers that control moving the 'innerPanel:
private void btnPrevious_Click(object sender, EventArgs e)
{
if(innerPanel.Left < LeftThreshold) innerPanel.Left += PanelMoveRight;
}
private void btnNext_Click(object sender, EventArgs e)
{
if (innerPanel.Left > RightThreshold) innerPanel.Left -= PanelMoveLeft;
}
The task is left up to you to figure out which direction, and by how many pixels, you want to move the 'innerPanel when the 'btnPrevious or 'btnNext Buttons are clicked. When you figure those out, assign the values to the constants used in the move button events.