New to Telerik UI for WinFormsStart a free 30-day trial

Represents a collection that provides notifications when items are added, removed, or when the list is refreshed.

Definition

Constructors

Initializes a new instance of the NotifyCollection<T> class.

C#
public NotifyCollection()

Initializes a new instance of the NotifyCollection<T> class with the specified list.

C#
public NotifyCollection(IList<T> list)
Parameters:listIList<T>

The list to wrap as a NotifyCollection.

Fields

C#
public static NotifyCollection<T> Empty

Properties

C#
protected bool Suspended { get; }
C#
protected int Version { get; }

Methods

Adds multiple items to the collection in a batch operation.

C#
public void AddRange(IEnumerable<T> items)
Parameters:itemsIEnumerable<T>

The enumerable collection of items to add.

Remarks:

This method uses BeginUpdate/EndUpdate to perform a batch operation with a single notification.

Adds multiple items to the collection in a batch operation.

C#
public void AddRange(params T[] items)
Parameters:itemsT[]

The items to add to the collection.

Remarks:

This method uses BeginUpdate/EndUpdate to perform a batch operation with a single notification.

Suspends change notifications until EndUpdate is called.

C#
public void BeginUpdate()
Remarks:

Use this method to perform multiple operations without triggering notifications for each change. Always pair with EndUpdate to resume notifications.

C#
protected override void ClearItems()

Overrides: Collection<T>.ClearItems()

C#
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action, object item, int index)
Parameters:actionNotifyCollectionChangedActionitemobjectindexintReturns:

NotifyCollectionChangedEventArgs

C#
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action, object oldItem, object item, int index)
Parameters:actionNotifyCollectionChangedActionoldItemobjectitemobjectindexintReturns:

NotifyCollectionChangedEventArgs

C#
protected virtual NotifyCollectionChangedEventArgs CreateEventArguments(NotifyCollectionChangedAction action)
Parameters:actionNotifyCollectionChangedActionReturns:

NotifyCollectionChangedEventArgs

Defers the refresh.

C#
public virtual IDisposable DeferRefresh()
Returns:

IDisposable

Resumes change notifications and fires any pending notifications.

C#
public void EndUpdate()
C#
public virtual void EndUpdate(bool notify)
Parameters:notifybool
C#
protected override void InsertItem(int index, T item)
Parameters:indexintitemT

Overrides: Collection<T>.InsertItem(int, T)

Moves an item from one index to another.

C#
public void Move(int oldIndex, int newIndex)
Parameters:oldIndexint

The current index of the item.

newIndexint

The target index for the item.

C#
protected virtual void MoveItem(int oldIndex, int newIndex)
Parameters:oldIndexintnewIndexint
C#
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs
C#
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
Parameters:ePropertyChangedEventArgs
C#
protected void OnPropertyChanged(string propertyName)
Parameters:propertyNamestring
C#
protected override void RemoveItem(int index)
Parameters:indexint

Overrides: Collection<T>.RemoveItem(int)

C#
protected override void SetItem(int index, T item)
Parameters:indexintitemT

Overrides: Collection<T>.SetItem(int, T)

Events

Occurs when the collection changes.

C#
public event NotifyCollectionChangedEventHandler CollectionChanged

Implements: INotifyCollectionChanged.CollectionChanged

C#
public event PropertyChangedEventHandler PropertyChanged

Implements: INotifyPropertyChanged.PropertyChanged