Reputation: 39
The purpose of my little program is when you click on a button you can make a checkbox appear on the winForm. I added a groupbox to make it look more "structured". Everything works fine but the problem is when I click on my button the Checkbox appears behind the groupbox and not on it.
Here is the code of the groupbox:
GroupBox GrpGoals = new GroupBox();
GrpGoals.Name = "GrpGoals";
GrpGoals.Text = "Micro Goals";
GrpGoals.Location = new Point(13, 4);
Controls.Add(GrpGoals);
Here is the code to create the checkbox:
private void CheckBoxes(string name)
{
CheckBox Chk = new CheckBox();
Chk.AutoSize = true;
Chk.Location = new Point(7, 21);
Chk.Name = name;
Chk.Text = name;
Controls.Add(Chk);
}
Upvotes: 0
Views: 343
Reputation: 314
private void CheckBoxes(string name)
{
CheckBox Chk = new CheckBox();
Chk.AutoSize = true;
Chk.Location = new Point(7, 21);
Chk.Name = name;
Chk.Text = name;
GrpGoals.Controls.Add(Chk);
}
Upvotes: 2