I need to create an array of label and text boxes dynamically.
I have a groupBox and I need to add the above to it. What is the best way to align then correctly? How do you get the location?
below does not work
public void TestCreateInputLabelAndTextBox()
{
foreach (Parameter parameter in Params)
{
var lbl = new Label();
lbl.Name = "lbl" + parameter.Name;
lbl.Text = parameter.Name;
lbl.AutoSize = true;
lbl.Location = new Point(7, 30);
lbl.Name = "label1";
lbl.Size = new Size(35, 13);
var txtBox = new TextBox();
txtBox.Name = "txt" + parameter.Name;
txtBox.Text = parameter.Name;
txtBox.Location = new Point(20, 20);
txtBox.Location = new Point(49, 22);
txtBox.Size = new Size(100, 20);
groupBox1.Controls.Add(lbl);
groupBox1.Controls.Add(txtBox);
}
}
How do you do it?
FlowLayoutPanel, TableLayoutPanel, etc for aligning purpose.