c# - Not all dynamic labels are being created -


i have 4 labels need created , placed dynamically, however, first 2 being created , placed.

here 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 output:

display

please help.

you using same x , y location second, third , fourth labels. causing them stacked on top of each other, appearing visually if first 2 being created. change x or y values third , fourth ones 4 combinations unique , problem solved.


Comments