public void AddFlats(string name, float area) { Flat flat = new Flat { Name = name, Area = area }; flats.Add(flat); }
public CalculatePrice(Model model, Flat template) { InitializeComponent(); this.model = model; var prop = typeof(Flat).GetProperties(); for (int i = 3; i < prop.Length; i++) { tableFactors.RowCount++; tableFactors.RowStyles.Add(new RowStyle(SizeType.Absolute, 25F)); tableFactors.Controls.Add(new Label() { Text = prop[i].Name, TextAlign = ContentAlignment.MiddleCenter }, 0, tableFactors.RowCount - 1); Control control; if (prop[i].PropertyType == typeof(int)) { control = new CalcNumUpDown() { Param = prop[i].Name, Maximum = int.MaxValue, Value = (int)prop[i].GetValue(template) }; } else { CalcComboBox cBox = new CalcComboBox() { Param = prop[i].Name }; foreach (object element in prop[i].PropertyType.GetEnumValues()) { cBox.Items.Add(element); } cBox.SelectedItem = prop[i].GetValue(template); control = cBox; } tableFactors.Controls.Add(control, 1, tableFactors.RowCount - 1); } CalcPriceText(); }