public static VehicleItem CreateInstance(string itemName) { if (Vehicle == null) { Vehicle = new VehicleItem(itemName); } return(Vehicle); }
private void ItemAdd_Click(object sender, EventArgs e) { ListViewItem newItem = null; if (ItemVehicle.Checked) { VehicleItem.CreateInstance(ItemName.Text); if (CollegeListView.Items.Count != 0) { if (CollegeListView.FindItemWithText(VehicleItem.GetName(), true, 0) == null) { newItem = new ListViewItem(VehicleItem.GetName()); } else { return; } } else { newItem = new ListViewItem(VehicleItem.GetName()); } } else if (ItemDorm.Checked) { DormItem newDormItem = new DormItem(ItemName.Text); newItem = new ListViewItem(newDormItem.GetName()); } else if (ItemClass.Checked) { ClassItem newClassItem = new ClassItem(ItemName.Text); newItem = new ListViewItem(newClassItem.GetName()); } else { return; } CollegeListView.Items.Add(newItem); }