public INIDetails(StoreParams sp) { this.sp = sp; int i = 0; int height = 30; foreach (System.Reflection.PropertyInfo pi in sp.GetType().GetProperties()) { Label lbl = new Label(); lbl.Name = pi.Name + "lbl"; lbl.Text = pi.Name; lbl.Width = 160; lbl.Top = i*height + 10; this.Controls.Add(lbl); TextBox box = new TextBox(); box.Name = pi.Name; box.Text = pi.GetValue(sp, null).ToString(); box.Width = 60; box.Left = 170; box.Top = i * height + 10; this.Controls.Add(box); boxes.Add(box); ++i; } InitializeComponent(); this.Height = i * height + 100; this.Width = 170 + 60 + 20; ok.Top = cancel.Top = button1.Top = this.Height - 60; }