private void dataGridItems_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { ItemUpdateForm itemUpdate = new ItemUpdateForm(); int rowIndex = e.RowIndex; itemUpdate.txtBoxItemID.Text = this.dataGridItems.Rows[rowIndex].Cells[0].Value.ToString(); itemUpdate.txtBoxItemName.Text = this.dataGridItems.Rows[rowIndex].Cells[1].Value.ToString(); itemUpdate.txtBoxItemType.Text = this.dataGridItems.Rows[rowIndex].Cells[2].Value.ToString(); itemUpdate.txtBoxBuyPrice.Text = this.dataGridItems.Rows[rowIndex].Cells[3].Value.ToString(); itemUpdate.txtBoxSellPrice.Text = this.dataGridItems.Rows[rowIndex].Cells[4].Value.ToString(); itemUpdate.txtBoxQnt.Text = this.dataGridItems.Rows[rowIndex].Cells[5].Value.ToString(); itemUpdate.cmbBoxSupplier.Text = this.dataGridItems.Rows[rowIndex].Cells[8].Value.ToString(); itemUpdate.Show(); }
private void btnUpdate_Click(object sender, EventArgs e) { if (rowIndex.Equals(null)) { MessageBox.Show("Item Not Selected!"); } else { ItemUpdateForm itemUpdate = new ItemUpdateForm(); itemUpdate.txtBoxItemID.Text = this.dataGridItems.Rows[rowIndex].Cells[0].Value.ToString(); itemUpdate.txtBoxItemName.Text = this.dataGridItems.Rows[rowIndex].Cells[1].Value.ToString(); itemUpdate.txtBoxItemType.Text = this.dataGridItems.Rows[rowIndex].Cells[2].Value.ToString(); itemUpdate.txtBoxBuyPrice.Text = this.dataGridItems.Rows[rowIndex].Cells[3].Value.ToString(); itemUpdate.txtBoxSellPrice.Text = this.dataGridItems.Rows[rowIndex].Cells[4].Value.ToString(); itemUpdate.txtBoxQnt.Text = this.dataGridItems.Rows[rowIndex].Cells[5].Value.ToString(); itemUpdate.cmbBoxSupplier.Text = this.dataGridItems.Rows[rowIndex].Cells[8].Value.ToString(); itemUpdate.Show(); } }