Reputation: 974
I have four labels that need to be created and placed dynamically, however, only the first two are being created and placed.
Here is the code:
int x = 10; int y = 50;
pnlRepShow.Controls.Add(new Label { Text = "Product Name:", Height = 40, Width = 100, Name = "Label" + y, Location = new Point(x, y) });
pnlRepShow.Controls.Add(new Label { Text = "Previous Stock:", Height = 40, Width = 100, Name = "Label" + y, Location = new Point(x, y + 100) });
pnlRepShow.Controls.Add(new Label { Text = "Current Stock:", Height = 40, Width = 100, Name = "Label" + y, Location = new Point(x, y + 100) });
pnlRepShow.Controls.Add(new Label { Text = "Difference:", Height = 40, Width = 100, Name = "Label" + y, Location = new Point(x, y + 100) });
Here is the output:
Please help.
Upvotes: 0
Views: 24
Reputation: 129
You are using the same x and y location for your second, third and fourth labels. This is causing them to be stacked on top of each other, appearing visually as if only the first two are actually being created. Change your x or y values for the third and fourth ones so that all four combinations are unique and your problem will be solved.
Upvotes: 1