private void button2_Click(object sender, EventArgs e) { if (dtvProfessor != null) { DataGridViewSelectedCellCollection selectedCells = dtvProfessor.SelectedCells; string matricula = selectedCells[0].FormattedValue.ToString(); ProfessorRepositorio professorRepositorio = new ProfessorRepositorio(); if (professorRepositorio.excluiProfessor(matricula) == 1) { MessageBox.Show("Professor excluído com sucesso!"); btnBuscarProfessor_Click(sender, e); } } }