I assume that you are using WinForm
I have created DemoForm and added on it
FlowLayoutPanel
(panel) and
NumericUpDown
(numericUpDownMargin)
here is some code
public partial class DemoForm : Form
{
private List<PictureBox> pictures;
private int n = 16;
public DemoForm()
{
InitializeComponent();
panel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
numericUpDownMargin.ValueChanged += MarginValueChanged;
pictures = new List<PictureBox>();
for(int i=0; i<n; i++)
{
var picture = new PictureBox();
var bmp = new Bitmap(@"path to your image");
picture.Image = bmp;
picture.Size = new Size(150,150);
pictures.Add(picture);
panel.Controls.Add(picture);
picture.Visible = true;
}
}
private void MarginValueChanged(object sender, EventArgs e)
{
int margin = (int) numericUpDownMargin.Value;
panel.SuspendLayout();
foreach (var pictureBox in pictures)
pictureBox.Margin = new Padding(margin);
panel.ResumeLayout();
}
}