private void computerDataGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e) { ItemsDatabase db = new ItemsDatabase(); var row = softwareDataGrid.CurrentCell.RowIndex; var column = softwareDataGrid.CurrentCell.ColumnIndex; int noOfCores = Convert.ToInt32(computerDataGrid.Rows[row].Cells[0].Value); int amountOfRAM = Convert.ToInt32(computerDataGrid.Rows[row].Cells[1].Value); int hddSize = Convert.ToInt32(computerDataGrid.Rows[row].Cells[2].Value); double weight = Convert.ToDouble(computerDataGrid.Rows[row].Cells[3].Value); string itemID = hardwareDataGrid.Rows[row].Cells[4].Value.ToString(); string itemName = hardwareDataGrid.Rows[row].Cells[5].Value.ToString(); double price = Convert.ToDouble(hardwareDataGrid.Rows[row].Cells[6].Value); Computer computer = new Computer(itemID, itemName, price, weight, noOfCores, amountOfRAM, hddSize); db.EditComputer(computer); }