private void deleteTeamButton_Click(object sender, EventArgs e) { if (teamGrid.DataSource != null) { int rowIndex = teamGrid.CurrentRow.Index; string teamName = teamGrid.Rows[rowIndex].Cells[0].Value.ToString(); DialogResult dr = MessageBox.Show(string.Format("Are you sure to delete '{0}' from the database?", teamName), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { TeamHandler.DeleteTeam(teamName); MessageBox.Show("Deleted"); teamGrid.DataSource = TeamHandler.GetViewAbleTeams(); } } }