private void m_dataGrid_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { if (m_dataGrid.Rows[e.RowIndex].IsNewRow) { if (m_actorInformationViewModel.Actors.Count == e.RowIndex + 1) { var actorsToRemove = new HashSet <VoiceActor.VoiceActor>(); actorsToRemove.Add(m_actorInformationViewModel.Actors[e.RowIndex]); m_actorInformationViewModel.DeleteVoiceActors(actorsToRemove); m_dataGrid.CancelEdit(); } return; } if (m_actorInformationViewModel.ValidateActor(e.RowIndex) == VoiceActorInformationViewModel.ActorValidationState.NoName) { e.Cancel = true; if (!m_inEndEdit) { MessageBox.Show(LocalizationManager.GetString("DialogBoxes.VoiceActorInformation.InvalidName", "Actor Name must be provided.")); if (m_dataGrid.CurrentCellAddress.X != ActorName.Index) { m_dataGrid.CurrentCell = m_dataGrid.Rows[e.RowIndex].Cells[ActorName.Index]; } } } }
private void DeleteActor(int iRow) { Debug.Assert(m_dataGrid.Rows[iRow].Selected); if (GetCountOfConfirmedActorsToDelete() == 0) { return; } m_actorInformationViewModel.DeleteVoiceActors(new HashSet <VoiceActor.VoiceActor> { m_actorInformationViewModel.Actors[iRow] }); }