public void ICVF_RemoveAt() { EntitySet <City> entitySet; EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet); IEditableCollectionView view = this.GetIECV(entityCollection); City city = (City)view.AddNew(); city.Name = "Des Moines"; city.CountyName = "King"; city.StateName = "WA"; view.CommitNew(); entityCollection.Add(this.CreateLocalCity("Normandy Park")); entityCollection.Add(this.CreateLocalCity("SeaTac")); // This one was added through the view and will be removed from both city = entityCollection.ElementAt(0); view.RemoveAt(0); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the entity at index 0."); Assert.IsFalse(entitySet.Contains(city), "EntitySet should no longer contain the entity at index 0."); // This one was added directly and will only be removed for the collection city = entityCollection.ElementAt(1); view.RemoveAt(1); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the entity at index 1."); Assert.IsTrue(entitySet.Contains(city), "EntitySet should still contain the entity at index 1."); }
private void listBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) { mouseClickedOnListBox = true; DependencyObject dep = (DependencyObject)e.OriginalSource; e.Handled = true; while ((dep != null) && !(dep is System.Windows.Controls.ListBoxItem)) { dep = System.Windows.Media.VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } int index = listBox.ItemContainerGenerator.IndexFromContainer(dep); listBox.SelectedIndex = index; this.confirmCompletion(false); // Remove selected item from list if tags autocomplete if (this.controller.autocompleteType == 1) { IEditableCollectionView items = listBox.Items; //Cast to interface if (items.CanRemove) { items.RemoveAt(index); } } }
/// <summary> /// Removes the item at the specified position from the collection. /// </summary> /// <param name="index">The position of the item to remove.</param> void IEditableCollectionView.RemoveAt(Int32 index) { IEditableCollectionView iEditableCollectionView = this.currentView as IEditableCollectionView; if (iEditableCollectionView == null) { throw new InvalidOperationException(ExceptionMessage.Format(ExceptionMessages.MemberNotAllowedForView, "RemoveAt")); } iEditableCollectionView.RemoveAt(index); }
//удалить строку private void deletestring_Click(object sender, RoutedEventArgs e) { IEditableCollectionView iecv = CollectionViewSource.GetDefaultView(DataGrid1.ItemsSource) as IEditableCollectionView; while (DataGrid1.SelectedIndex >= 0) { int selectedIndex = DataGrid1.SelectedIndex; DataGridRow dgr = DataGrid1.ItemContainerGenerator.ContainerFromIndex(selectedIndex) as DataGridRow; dgr.IsSelected = false; if (iecv.IsEditingItem) { iecv.CommitEdit(); iecv.RemoveAt(selectedIndex); } else { iecv.RemoveAt(selectedIndex); } } #region //DataRowView rowView = DataGrid1.SelectedItems[0] as DataRowView; // DataRowView row = (DataRowView)DataGrid1.SelectedCells.; //ObservableCollection<DataRow> data = (ObservableCollection<DataRow>)DataGrid1.ItemsSource; //data.Remove(row); //DataGrid1.Items.Remove(selectedRow); // List.Remove(SelectedDataGrid1Item); // DataSet1.OurTableRow GetSelectedRow() // { // String SelectedPraktikaID = DataGrid1.CurrentRow.Cells["PropId"].value.toString; // DataSet1.OurTableRow SelectedRow = //OurTableDataTable.FindByPropID(SelectedPraktikaID); // return SelectedRow; // } // GetSelectedRow().Delete(); }
/// <summary> /// Remove the item at the given index from the underlying collection. /// The index is interpreted with respect to the view (not with respect to /// the underlying collection). /// </summary> void IEditableCollectionView.RemoveAt(int index) { IEditableCollectionView ecv = ProxiedView as IEditableCollectionView; if (ecv != null) { ecv.RemoveAt(index); } else { throw new InvalidOperationException(SR.Get(SRID.MemberNotAllowedForView, "RemoveAt")); } }
// Token: 0x0600740E RID: 29710 RVA: 0x00212F08 File Offset: 0x00211108 void IEditableCollectionView.RemoveAt(int index) { IEditableCollectionView editableCollectionView = this.ProxiedView as IEditableCollectionView; if (editableCollectionView != null) { editableCollectionView.RemoveAt(index); return; } throw new InvalidOperationException(SR.Get("MemberNotAllowedForView", new object[] { "RemoveAt" })); }
public void ICVF_RemoveAt() { EntitySet <City> entitySet = this.CreateEntitySet <City>(); IEditableCollectionView view = this.GetIECV(entitySet); entitySet.Add(this.CreateLocalCity("Renton")); entitySet.Add(this.CreateLocalCity("Kent")); entitySet.Add(this.CreateLocalCity("Auburn")); City city = entitySet.ElementAt(1); view.RemoveAt(1); Assert.IsFalse(entitySet.Contains(city), "EntitySet should no longer contain the entity at index 1."); }
private void DeleteRecord() { MessageBoxResult answer = MessageBox.Show("Are you sure you want to delete row " + (dgAnimals.SelectedIndex + 1) + "?", "Delete", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (answer == MessageBoxResult.OK) { IEditableCollectionView items = dgAnimals.Items; if (items.CanRemove) { items.RemoveAt(dgAnimals.SelectedIndex); } /* The solution throws an OutOFRange Exception when user uses sorting for columns, because it's messing up the indexes * animalList.RemoveAt(dgAnimals.SelectedIndex); * dgAnimals.Items.Refresh(); */ } }
public void RemoveAt(int index) { _collectionView.RemoveAt(index); }