for loop - C# Generating Labels Dynamically -


i have got below code generate labels using loop, there problem loop, if productlist has 4 items, generates 1 label instead of 4. can't figure out problem is.

list<models.car> carlist = carcontroller.getcars();     (int = 0; < carlist.count; i++)  {     list<models.product> productlist = productcontroller.getproducts(carlist[i].model);      (int j = 0; j < productlist.count; j++)      {         productlabels.add(new label());         var productlabelspoint = new system.drawing.point(200, 40 + * 50);         (productlabels[j] label).location = productlabelspoint;         (productlabels[j] label).size = new system.drawing.size(150, 15);         (productlabels[j] label).text = productlist[j].title;         this.tab.tabpages["tab1"].controls.add((productlabels[j] label));     } } 

this relies on i, not on j:

system.drawing.point productlabelspoint = new system.drawing.point(200, 40 + * 50); 

so might drawing labels 1 on top of other. in case, you'd need add j mix, example this:

system.drawing.point productlabelspoint = new system.drawing.point(200, 40 + * 50 + j * 50); 

i change way referencing label. (i can't tell context if doing okay or not, depends how productlabels variables has been instantiated.)