private void productDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { AddProductUi addProductUi = new AddProductUi(this); try { if (productDataGridView.Columns[e.ColumnIndex].Name == "Edit") { if (e.RowIndex < 0) { return; } if (productDataGridView.CurrentRow != null) { productDataGridView.CurrentRow.Selected = true; } //_product.Id = Convert.ToInt32(productDataGridView.Rows[e.RowIndex].Cells[1].Value); addProductUi.id = Convert.ToInt32(productDataGridView.Rows[e.RowIndex].Cells[1].Value); addProductUi.codeTextBox.Text = productDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); addProductUi.nameTextBox.Text = productDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); //addProductUi.categoryComboBox.Text = productDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString(); addProductUi.categoryText = productDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString(); addProductUi.reorderLevelNumericUpDown.Text = productDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString(); addProductUi.descriptionTextBox.Text = productDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString(); //MessageBox.Show(addProductUi.categoryComboBox.Text); addProductUi.saveOrUpdateButton.Text = @"Update"; addProductUi.categoryErrorLabel.Text = ""; addProductUi.ShowDialog(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void addProduct_Click(object sender, EventArgs e) { AddProductUi addProduct = new AddProductUi(this); addProduct.ShowDialog(); }