public class Product
{
private IList controlsToAdd = new ArrayList();
public IList ControlsToAdd{get{return controlsToAdd;}}
public Product(int baseX, int currentY, DataRow someData)
{
TextBox text = new TextBox();
text.Location = new Point(baseX, currentY);
controlsToAdd.Add(text);
}
}
public class SomeForm
{
public void Method(DataSet ds)
{
int currentY = 10;
int heightOfControl = 30;
int baseX = 10;
foreach(DataRow dr in ds.Tables[0].Rows)
{
Product p = new Product(currentY);
foreach(Control c in p.ControlsToAdd)
{
this.panel1.Controls.Add(c);
}
currentY += heightOfControl;
}
}
}