public frmEditIEditable(IEditable item, frmMain main) { InitializeComponent(); _controls = new List <Control>(); _item = item; _main = main; int height = 0; int panelHeight = 28; foreach (PropertyDescriptor editableProperty in _item.GetEditableProperties()) { Panel pnl = new Panel(); pnl.Parent = this; pnl.Dock = DockStyle.Top; pnl.Padding = new Padding(6); pnl.Height = panelHeight; Label lbl = new Label(); lbl.Parent = pnl; lbl.AutoSize = false; lbl.Location = new Point(6, 6); lbl.TextAlign = ContentAlignment.MiddleLeft; lbl.Size = new Size(100, 21); lbl.Text = editableProperty.Caption; TextBox tb = new TextBox(); tb.Parent = pnl; tb.Location = new Point(110, 6); tb.Width = 260; tb.Text = Convert.ToString(_item[editableProperty.Key]); tb.Tag = editableProperty; tb.Validating += new CancelEventHandler(tb_Validating); _controls.Add(tb); height += panelHeight; } height += panelHeight + 10; this.Width = 394; this.Height = height + this.pnlFooter.Height; if (item is IRenderable) { this.Text = "Edit: " + ((IRenderable)item).Name; } else { this.Text = ""; } }