private void btDelete_Click(object sender, EventArgs e) { var selectedRows = dgvDoctors.SelectedRows; if (selectedRows.Count != 1) { MessageBox.Show("select one row!"); } else { var row = selectedRows[0]; var doctor = (Doctor)row.DataBoundItem; viewModel.DeleteDoctor(doctor); } }