/// <summary> /// This method launches the edit a game form on top of the library. /// </summary> private void EditAGame(object sender, EventArgs e) { if (dgvLibrary.SelectedCells.Count > 0) { string title; string platform; string selectedCellValue = dgvLibrary.SelectedCells[0].Value.ToString(); int rowIndex = dgvLibrary.CurrentCell.RowIndex; int columnIndex = dgvLibrary.CurrentCell.ColumnIndex; columnIndex = columnIndex == 0 ? columnIndex++ : columnIndex--; string otherCellValue = dgvLibrary.Rows[rowIndex].Cells[columnIndex].Value.ToString(); title = columnIndex == 0 ? otherCellValue : selectedCellValue; platform = columnIndex == 0 ? selectedCellValue : otherCellValue; game = new Game(title, platform); addAGame = new AddAGame("Edit"); addAGame.Game = game; addAGame.User = user; addAGame.ShowDialog(this); MyLibrary_Load(sender, e); } }
/// <summary> /// This method launches the add a game form on top of the library. /// </summary> public void AddAGame(object sender, EventArgs e) { addAGame = new AddAGame("Add"); addAGame.User = user; addAGame.ShowDialog(this); MyLibrary_Load(sender, e); }