private void softwareDataGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e) { ItemsDatabase db = new ItemsDatabase(); var row = softwareDataGrid.CurrentCell.RowIndex; var column = softwareDataGrid.CurrentCell.ColumnIndex; string licenceKey = softwareDataGrid.Rows[row].Cells[0].Value.ToString(); double sizeInMB = Convert.ToDouble(softwareDataGrid.Rows[row].Cells[1].Value); string itemID = hardwareDataGrid.Rows[row].Cells[2].Value.ToString(); string itemName = hardwareDataGrid.Rows[row].Cells[3].Value.ToString(); double price = Convert.ToDouble(hardwareDataGrid.Rows[row].Cells[4].Value); SoftwareItem softwareItem = new SoftwareItem(itemID, itemName, price, licenceKey, sizeInMB); db.EditSoftwareItem(softwareItem); }