System.Collections.IList buttonNames = new System.Collections.ArrayList(new String[] { "one", "two" });
private void Form1_Load ( object sender, EventArgs e )
{
Size defaultButtonSize = new Size(75, 23);
const int top = 10;
const int verticalPadding = 4;
int i = 0;
foreach (string name in buttonNames)
{
Button button = new Button();
this.Controls.Add(button);
button.Size = defaultButtonSize;
button.Name = name;
button.Text = name;
button.Location = new Point(10, top + i * (button.Height + verticalPadding));
++i;
}
}