I'm adding buttons to a panel in a loop from AppSettings keys, but why it isn't adding a little spaces between them?
foreach (var key in System.Configuration.ConfigurationSettings.AppSettings)
{
x = 4;
y = panel1.Controls.Count * 30;
Button button = new Button();
button.Text = key.ToString();
button.Visible = true;
button.Location = new Point(x+3, y+10);
button.Height = 45;
button.Width = 308;
button.TextAlign = ContentAlignment.MiddleLeft;
button.Show();
panel1.Controls.Add(button);
}
How it is look now:
And what I want:


Panelin the first place. Use aTableLayoutPanelorFlowLayoutPanel. That way, you don't have to care about theLocationat all as the parent will handle the layout.