private void AddInput(Models.FormProperty formProperty, int y) { var label = new Label(); label.Text = formProperty.Name; label.Location = new Point(0, y); var textBox = new TextBox(); textBox.Location = new Point(150, y); textBox.Size = new System.Drawing.Size(319, 21); textBox.TabIndex = 2; textBox.TextChanged += new EventHandler(delegate(Object o, EventArgs a) { var value = textBox.Text; var property = new Models.NewFormProperty() { Id = formProperty.Id, Value = value }; try { var find = this.newForm.Properties.Find(e => e.Id == property.Id); find.Value = property.Value; } catch (Exception e) { this.newForm.Properties.Add(property); } }); this.panel1.Controls.Add(textBox); this.panel1.Controls.Add(label); }
private void AddDropdown(Models.FormProperty formProperty, Models.Form form, int y) { var label = new Label(); label.Text = formProperty.Name; label.Location = new Point(0, y); var comboBox = new ComboBox(); comboBox.Location = new Point(150, y); comboBox.Name = formProperty.Id; comboBox.Size = new System.Drawing.Size(319, 21); comboBox.TabIndex = 2; comboBox.Items.Clear(); foreach (var p in formProperty.EnumValues) { if (p != null || p.Name != null) { comboBox.Items.Add(p); } } comboBox.SelectedIndexChanged += new EventHandler(delegate(Object o, EventArgs a) { var selected = (Models.EnumValue)comboBox.SelectedItem; var property = new Models.NewFormProperty() { Id = formProperty.Id, Value = selected.Name }; try { var find = this.newForm.Properties.Find(e => e.Id == property.Id); find.Value = property.Value; } catch (Exception e) { this.newForm.Properties.Add(property); } }); this.panel1.Controls.Add(comboBox); this.panel1.Controls.Add(label); }