All pastes #485986 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-13 18:05 UTC
rendered paste body
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;
		}
	}
}