private void buttonDeleteProduct_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Delete Product?", "Checkbox", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { var cell = this.dataGridViewProductUserControl.SelectedCells[0]; int clickedCellID = Reader.GetProductsDataTable().Rows[cell.RowIndex].Field <int>("ProductID"); Deleter.DeleteProduct(clickedCellID); MessageBox.Show("Product deleted!"); SetUpDefaultDataTableProducts(); } catch (Exception) { MessageBox.Show("This product is part of an existing order and cannot be deleted"); } } }