private void ButtonEdit_Click(object sender, EventArgs e) { if (listviewObject.SelectedItems.Count == 0) { MessageBox.Show("Select object!"); return; } Type type = data.objectTypes.First(t => t.GetCustomAttribute <DescriptionAttribute>(true).Description == listviewObject.SelectedItems[0].SubItems[1].Text); Form formEditObject = new ObjectForm(type, FormType.Edit, "formEditObject", data, listviewObject); formEditObject.Show(); }
private void ButtonAdd_Click(object sender, EventArgs e) { Type type = null; try { type = data.objectTypes.First(t => t.GetCustomAttribute <DescriptionAttribute>(true).Description == comboboxObject.Text); } catch { MessageBox.Show("Incorrect data!"); return; } Form formAddObject = new ObjectForm(type, FormType.Add, "formAddObject", data, listviewObject); formAddObject.Show(); }