private void infoButton_Click(object sender, EventArgs e) { if (NoSelectedOrEmptyList()) { int index = productListBox.SelectedIndex; Product p = (Product)productListBox.Items[index]; ProductForm prodForm = new ProductForm(p, false); prodForm.Enabled(); prodForm.ShowDialog(); } }
private void addButton_Click(object sender, EventArgs e) { Product product = new Product(); var prodForm = new ProductForm(product, true); if (prodForm.ShowDialog() == DialogResult.OK) { productListBox.Items.Add(product); } }
private void editButton_Click(object sender, EventArgs e) { if (NoSelectedOrEmptyList()) { int index = productListBox.SelectedIndex; Product p = productListBox.SelectedItem as Product; ProductForm prodForm = new ProductForm(p, false); if (prodForm.ShowDialog() == DialogResult.OK) { productListBox.Items.RemoveAt(index); productListBox.Items.Insert(index, p); productListBox.SelectedIndex = index; } } }