New to Telerik UI for WinForms? Start a free 30-day trial

Provides an abstract base class for collection views that support filtering, sorting, grouping, and paging operations on strongly-typed data item collections.

RadCollectionView serves as the foundation for data binding scenarios in RadControls, providing a rich set of data manipulation capabilities including filtering, sorting, grouping, and paging. It implements multiple collection interfaces to ensure compatibility with various data binding patterns and frameworks.

The collection view acts as a layer between raw data sources and UI controls, allowing for complex data operations without modifying the underlying data. It supports expression-based filtering, multi-level sorting, hierarchical grouping, and efficient pagination for large datasets.

Key features include change notifications through INotifyCollectionChanged and INotifyPropertyChanged, current item tracking, deferred refresh capabilities, and thread-safe operations for multi-threaded environments.

Definition

Namespace:Telerik.WinControls.Data

Assembly:Telerik.WinControls.dll

Type Parameters:

TDataItem

The type of data items in the collection, which must implement IDataItem.

Syntax:

C#
public abstract class RadCollectionView<TDataItem> : ICollectionView<TDataItem>, IPagedCollectionView, IReadOnlyCollection<TDataItem>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged where TDataItem : IDataItem

Inheritance: objectRadCollectionView<TDataItem>

Derived Classes: RadDataView<TDataItem>

Implements: ICollectionView<TDataItem>IEnumerableINotifyCollectionChangedINotifyPropertyChangedIPagedCollectionViewIReadOnlyCollection<TDataItem>...

Constructors

Initializes the view from a source sequence and subscribes to its collection notifications when available.

C#
public RadCollectionView(IEnumerable<TDataItem> collection)
Parameters:collectionIEnumerable<TDataItem>

The sequence whose items are projected by the view.

Exceptions: ArgumentNullException

collection is null.

Properties

Gets or sets a value indicating whether filtering will be performed or it will be handled by the user/data source.

C#
[Browsable(false)]
public bool BypassFilter { get; set; }

Gets or sets a value indicating whether sorting will be performed or it will be handled by the user/data source.

C#
[Browsable(false)]
public bool BypassSort { get; set; }

Gets a value that indicates whether the IPagedCollectionView.PageIndex value is allowed to change.

C#
public virtual bool CanChangePage { get; }
Property Value:

true if the IPagedCollectionView.PageIndex value is allowed to change; otherwise, false.

Implements: IPagedCollectionView.CanChangePage

Gets or sets a value indicating whether this data view can filter.

C#
public virtual bool CanFilter { get; set; }
Property Value:

true if this instance can filter; otherwise, false.

Implements: ICollectionView<TDataItem>.CanFilter

Gets or sets a value indicating whether this data view can group.

C#
public virtual bool CanGroup { get; set; }
Property Value:

true if this instance can group; otherwise, false.

Implements: ICollectionView<TDataItem>.CanGroup

Gets or sets a value indicating whether this data view can be paginated.

C#
public virtual bool CanPage { get; set; }
Property Value:

true if this data view can be paginated; otherwise, false.

Implements: IPagedCollectionView.CanPage

Gets or sets a value indicating whether this data view can sort.

C#
public virtual bool CanSort { get; set; }
Property Value:

true if this instance can sort; otherwise, false.

Implements: ICollectionView<TDataItem>.CanSort

Indicates whether string comparisons of data are case-sensitive.

C#
[Browsable(true)]
public bool CaseSensitive { get; set; }

Gets or sets a value indicating whether [change current on add].

C#
public bool ChangeCurrentOnAdd { get; set; }
Property Value:

true if [change current on add]; otherwise, false.

Comparer

IComparer<TDataItem>

Gets or sets the comparer.

C#
[Browsable(false)]
public virtual IComparer<TDataItem> Comparer { get; set; }
Property Value:

The comparer.

Gets the count.

C#
public int Count { get; }
Property Value:

The count.

Implements: IReadOnlyCollection<TDataItem>.Count

CurrentItem

TDataItem

Gets or sets the current item.

C#
public TDataItem CurrentItem { get; }
Property Value:

The current item.

Implements: ICollectionView<TDataItem>.CurrentItem

Gets or sets the current position.

C#
public int CurrentPosition { get; protected set; }
Property Value:

The current position.

Implements: ICollectionView<TDataItem>.CurrentPosition

Default callback so that the default filtering expression parser can be substituted.

C#
public virtual Predicate<TDataItem> DefaultFilter { get; }

Gets the default group predicate.

C#
public virtual GroupPredicate<TDataItem> DefaultGroupPredicate { get; }
Property Value:

The default group predicate.

Filter

Predicate<TDataItem>

Provides a callback so that the default filtering expression parser can be substituted.

C#
public virtual Predicate<TDataItem> Filter { get; set; }

Implements: ICollectionView<TDataItem>.Filter

Gets or sets the filter expression.

C#
public virtual string FilterExpression { get; set; }
Property Value:

The filter expression.

GroupComparer

IComparer<Group<TDataItem>>

Gets or sets the comparer.

C#
[Browsable(false)]
public virtual IComparer<Group<TDataItem>> GroupComparer { get; set; }
Property Value:

The comparer.

Implements: ICollectionView<TDataItem>.GroupComparer

This property is used internally.

C#
public IGroupDescriptorCollectionFactory GroupDescriptorCollectionFactory { get; set; }

Gets the group descriptions.

C#
public GroupDescriptorCollection GroupDescriptors { get; }
Property Value:

The group descriptions.

Implements: ICollectionView<TDataItem>.GroupDescriptors

Gets or sets the factory used to create groups for this view.

C#
public virtual IGroupFactory<TDataItem> GroupFactory { get; set; }

Gets or sets the callback used by derived views to compute group keys.

C#
public virtual GroupPredicate<TDataItem> GroupPredicate { get; set; }

The base implementation returns null and ignores assignments.

Gets the groups.

C#
public virtual GroupCollection<TDataItem> Groups { get; }
Property Value:

The groups.

Implements: ICollectionView<TDataItem>.Groups

Indicates whether filtering, sorting, or grouping is active.

C#
protected bool HasDataOperation { get; }

Gets a value indicating whether this instance has filter applied.

C#
protected bool HasFilter { get; }
Property Value:

true if this instance has filter applied; otherwise, false.

Gets a value indicating whether this instance has group applied.

C#
protected bool HasGroup { get; }
Property Value:

true if this instance has group applied; otherwise, false.

Gets a value indicating whether this instance has sort applied.

C#
protected bool HasSort { get; }
Property Value:

true if this instance has sort applied; otherwise, false.

Gets a value that indicates whether the underlying collection provides change notifications.

C#
public bool IsDynamic { get; }
Property Value:

true if this instance is dynamic; otherwise, false.

Gets a value indicating whether this item collection is empty.

C#
public bool IsEmpty { get; }
Property Value:

true if this item collection is empty; otherwise, false.

Gets a value indicating whether this instance is incremental filtering.

C#
public bool IsIncrementalFiltering { get; }
Property Value:

true if this instance is incremental filtering; otherwise, false.

Indicates whether the view is inside a deferred update.

C#
protected bool IsInUpdate { get; }

Gets a value that indicates whether a page index change is in process.

C#
public virtual bool IsPageChanging { get; }
Property Value:

true if the page index is changing; otherwise, false.

Implements: IPagedCollectionView.IsPageChanging

Gets the total number of items in the source collection.

C#
public virtual int ItemCount { get; }
Property Value:

The total number of items in the source collection, or -1 if the total number is unknown.

Implements: IPagedCollectionView.ItemCount

Items

IList<TDataItem>

Gets the item list exposed by a derived view.

C#
protected virtual IList<TDataItem> Items { get; }

The base implementation returns null; derived views provide the collection used by indexing and enumeration.

Gets the zero-based index of the current page.

C#
public virtual int PageIndex { get; }
Property Value:

The zero-based index of the current page.

Implements: IPagedCollectionView.PageIndex

Gets or sets the number of items to display on a page.

C#
public virtual int PageSize { get; set; }
Property Value:

The number of items to display on a page.

Implements: IPagedCollectionView.PageSize

Gets or sets a value indicating whether paging is performed before grouping or vice versa.

C#
public virtual bool PagingBeforeGrouping { get; set; }
Property Value:

true if paging is performed before grouping; otherwise, false.

This property is used internally.

C#
public ISortDescriptorCollectionFactory SortDescriptorCollectionFactory { get; set; }

Gets the sort descriptions.

C#
public SortDescriptorCollection SortDescriptors { get; }
Property Value:

The sort descriptions.

Implements: ICollectionView<TDataItem>.SortDescriptors

SourceCollection

IEnumerable<TDataItem>

Gets the source collection.

C#
public virtual IEnumerable<TDataItem> SourceCollection { get; }
Property Value:

The source collection.

Implements: ICollectionView<TDataItem>.SourceCollection

this[int]

TDataItem

Gets the item at the specified index.

C#
public TDataItem this[int index] { get; }
Parameters:indexint

Implements: IReadOnlyCollection<TDataItem>.this[int]

Gets the total number of pages with the current page size.

C#
public virtual int TotalPages { get; }

Methods

Suspends event notification.

C#
public void BeginUpdate()

Clears cached filter-expression nodes and their per-thread evaluation contexts.

C#
public void ClearThreadedFilterNodes()

Determines whether [contains] [the specified item].

C#
public bool Contains(TDataItem item)
Parameters:itemTDataItem

The item.

Returns:

bool

true if [contains] [the specified item]; otherwise, false.

Implements: IReadOnlyCollection<TDataItem>.Contains(TDataItem)

Determines whether the specified group is present within this view.

C#
public bool ContainsGroup(Group<TDataItem> group)
Parameters:groupGroup<TDataItem>Returns:

bool

Copies to array.

C#
public void CopyTo(TDataItem[] array, int arrayIndex)
Parameters:arrayTDataItem[]

The array.

arrayIndexint

Index of the array.

Defers the refresh.

C#
public virtual IDisposable DeferRefresh()
Returns:

IDisposable

Resumes event notification.

C#
public void EndUpdate()

Resumes event notification.

C#
public void EndUpdate(bool notifyUpdates)
Parameters:notifyUpdatesbool

Provides a hook for derived views to resolve descriptor metadata before data operations.

C#
public virtual void EnsureDescriptors()

The base implementation does nothing.

Ensures the index of the page is within the valid pages range.

C#
protected virtual void EnsurePageIndex()

Evaluates the specified expression.

C#
public object Evaluate(string expression, IEnumerable<TDataItem> items)
Parameters:expressionstring

The expression.

itemsIEnumerable<TDataItem>

The items.

Returns:

object

Evaluates the specified expression.

C#
public object Evaluate(string expression, int startIndex, int count)
Parameters:expressionstring

The expression.

startIndexint

The start index.

countint

The count.

Returns:

object

Evaluates the specified expression.

C#
public object Evaluate(string expression, TDataItem item)
Parameters:expressionstring

The expression.

itemTDataItem

The item.

Returns:

object

Evaluates a descriptor expression against one item using this view's case-sensitivity setting.

C#
public bool FilterEvaluate(FilterDescriptor filterDescriptor, TDataItem item)
Parameters:filterDescriptorFilterDescriptor

The descriptor whose expression supplies the filter criteria.

itemTDataItem

The item whose descriptor fields are evaluated.

Returns:

bool

true when the descriptor has no expression or evaluates to a Boolean value of true; non-Boolean results also pass.

Finds the specified item index.

C#
public virtual TDataItem Find(int itemIndex, object dataBoundItem)
Parameters:itemIndexint

Index of the item.

dataBoundItemobject

The data bound item.

Returns:

TDataItem

Searches the Groups collection for a match, using the Keys in the provided group.

C#
public Group<TDataItem> FindGroup(Group<TDataItem> group)
Parameters:groupGroup<TDataItem>Returns:

Group<TDataItem>

Enumerates the items currently exposed by the view.

C#
public IEnumerator<TDataItem> GetEnumerator()
Returns:

IEnumerator<TDataItem>

Gets a field value used when evaluating a filter expression.

C#
protected virtual object GetFieldValue(TDataItem item, string fieldName)
Parameters:itemTDataItem

The item containing the field.

fieldNamestring

The field name referenced by the expression.

Returns:

object

The value returned by the item's field indexer.

Gets the page containing an item when a derived view supports paging.

C#
public virtual int GetItemPage(TDataItem item)
Parameters:itemTDataItem

The item whose page is requested.

Returns:

int

The zero-based page index, or -1 when the base implementation cannot provide one.

Indexes the of.

C#
public virtual int IndexOf(TDataItem item)
Parameters:itemTDataItem

The item.

Returns:

int

Implements: IReadOnlyCollection<TDataItem>.IndexOf(TDataItem)

Replaces the source sequence and updates the collection-change subscription.

C#
protected virtual void InitializeSource(IEnumerable<TDataItem> collection)
Parameters:collectionIEnumerable<TDataItem>

The sequence to observe and project.

Collection notifications are observed only when the sequence implements INotifyCollectionChanged.

Loads the data.

C#
public virtual void LoadData(IEnumerable<TDataItem> collection)
Parameters:collectionIEnumerable<TDataItem>

The collection.

Moves the current to.

C#
public bool MoveCurrentTo(TDataItem item)
Parameters:itemTDataItem

The item.

Returns:

bool

Implements: ICollectionView<TDataItem>.MoveCurrentTo(TDataItem)

Moves the current to first.

C#
public bool MoveCurrentToFirst()
Returns:

bool

Implements: ICollectionView<TDataItem>.MoveCurrentToFirst()

Moves the current to last.

C#
public bool MoveCurrentToLast()
Returns:

bool

Implements: ICollectionView<TDataItem>.MoveCurrentToLast()

Moves the current to next.

C#
public bool MoveCurrentToNext()
Returns:

bool

Implements: ICollectionView<TDataItem>.MoveCurrentToNext()

Moves the current to position.

C#
public bool MoveCurrentToPosition(int newPosition)
Parameters:newPositionint

The position.

Returns:

bool

Implements: ICollectionView<TDataItem>.MoveCurrentToPosition(int)

Moves the current to previous.

C#
public bool MoveCurrentToPrevious()
Returns:

bool

Implements: ICollectionView<TDataItem>.MoveCurrentToPrevious()

Sets the first page as the current page.

C#
public virtual bool MoveToFirstPage()
Returns:

bool

true if the operation was successful; otherwise, false.

Implements: IPagedCollectionView.MoveToFirstPage()

Sets the last page as the current page.

C#
public virtual bool MoveToLastPage()
Returns:

bool

true if the operation was successful; otherwise, false.

Implements: IPagedCollectionView.MoveToLastPage()

Moves to the page after the current page.

C#
public virtual bool MoveToNextPage()
Returns:

bool

true if the operation was successful; otherwise, false.

Implements: IPagedCollectionView.MoveToNextPage()

Requests a page move to the page at the specified zero-based index.

C#
public virtual bool MoveToPage(int pageIndex)
Parameters:pageIndexint

The zero-based index of the page to move to.

Returns:

bool

true if the operation was successful; otherwise, false.

Implements: IPagedCollectionView.MoveToPage(int)

Moves to the page before the current page.

C#
public virtual bool MoveToPreviousPage()
Returns:

bool

true if the operation was successful; otherwise, false.

Implements: IPagedCollectionView.MoveToPreviousPage()

Raises a view-change notification and updates the view version when the change can affect its projection.

C#
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs

The collection change to publish.

Raises CurrentChanged when the view is not inside a deferred update.

C#
protected virtual void OnCurrentChanged(EventArgs args)
Parameters:argsEventArgs

The event data describing the current-item change.

Raises CurrentChanging when the view is not inside a deferred update.

C#
protected virtual void OnCurrentChanging(CancelEventArgs args)
Parameters:argsCancelEventArgs

The event data; a handler can set Cancel to prevent the change.

Raises the NotifyPropertyChanged event

C#
protected virtual void OnNotifyPropertyChanged(PropertyChangedEventArgs e)
Parameters:ePropertyChangedEventArgs

Fires the PageChanged event.

C#
protected virtual void OnPageChanged()

Fires the PageChanging event. Returns the value of the Cancel event argument.

C#
protected virtual bool OnPageChanging(int newIndex)
Parameters:newIndexint

The new index.

Returns:

bool

True if the event was canceled, otherwise false.

Passeses the filter.

C#
public virtual bool PassesFilter(TDataItem item)
Parameters:itemTDataItem

The item.

Returns:

bool

Processes a source collection change by forwarding it to OnCollectionChanged(NotifyCollectionChangedEventArgs).

C#
protected virtual void ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs

The source collection change.

Refreshes this data view.

C#
public virtual void Refresh()

Implements: ICollectionView<TDataItem>.Refresh()

Raises a reset notification unless a deferred update is in progress.

C#
protected virtual void RefreshOverride()

Updates the current position and raises the corresponding changing and changed notifications.

C#
protected bool SetCurrentPositionCore(int newPosition, bool forceNotify, CurrentChangeReason reason)
Parameters:newPositionint

The requested zero-based position; values beyond the last item are reduced to the last position.

forceNotifybool

true to process the change even when the position is unchanged.

reasonCurrentChangeReason

The reason included in the current-item change event data.

Returns:

bool

true when the position update is accepted; false when it is unchanged or canceled.

The core update routine for the current position.

C#
protected virtual bool SetCurrentPositionCore(int newPosition, bool forceNotify)
Parameters:newPositionint

New position of the current item.

forceNotifybool

True to raise CurrentChanged regardless of whether actual position change is available.

Returns:

bool

Determines whether a source change requires the view version to advance.

C#
protected virtual bool VersionUpdateNeeded(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs

The source collection change.

Returns:

bool

true for structural changes or changes to fields used by filtering, sorting, or grouping.

Events

Occurs when the view's projected items change.

C#
public event NotifyCollectionChangedEventHandler CollectionChanged

Implements: ICollectionView<TDataItem>.CollectionChangedINotifyCollectionChanged.CollectionChanged

Occurs after the current item or position changes, except while an update is deferred.

C#
public event EventHandler CurrentChanged

Implements: ICollectionView<TDataItem>.CurrentChanged

Occurs before the current item or position changes, allowing the change to be canceled.

C#
public event CancelEventHandler CurrentChanging

Implements: ICollectionView<TDataItem>.CurrentChanging

Occurs when the IPagedCollectionView.PageIndex has changed.

C#
public event EventHandler<EventArgs> PageChanged

Implements: IPagedCollectionView.PageChanged

Occurs before the IPagedCollectionView.PageIndex is changed.

C#
public event EventHandler<PageChangingEventArgs> PageChanging

Implements: IPagedCollectionView.PageChanging

Occurs when a view property, such as its filter or descriptor collection, changes.

C#
public event PropertyChangedEventHandler PropertyChanged

Implements: INotifyPropertyChanged.PropertyChanged

In this article
DefinitionConstructorsRadCollectionView(IEnumerable<TDataItem>)PropertiesBypassFilterBypassSortCanChangePageCanFilterCanGroupCanPageCanSortCaseSensitiveChangeCurrentOnAddComparerCountCurrentItemCurrentPositionDefaultFilterDefaultGroupPredicateFilterFilterExpressionGroupComparerGroupDescriptorCollectionFactoryGroupDescriptorsGroupFactoryGroupPredicateGroupsHasDataOperationHasFilterHasGroupHasSortIsDynamicIsEmptyIsIncrementalFilteringIsInUpdateIsPageChangingItemCountItemsPageIndexPageSizePagingBeforeGroupingSortDescriptorCollectionFactorySortDescriptorsSourceCollectionthis[int]TotalPagesMethodsBeginUpdate()ClearThreadedFilterNodes()Contains(TDataItem)ContainsGroup(Group<TDataItem>)CopyTo(TDataItem[], int)DeferRefresh()EndUpdate()EndUpdate(bool)EnsureDescriptors()EnsurePageIndex()Evaluate(string, IEnumerable<TDataItem>)Evaluate(string, int, int)Evaluate(string, TDataItem)FilterEvaluate(FilterDescriptor, TDataItem)Find(int, object)FindGroup(Group<TDataItem>)GetEnumerator()GetFieldValue(TDataItem, string)GetItemPage(TDataItem)IndexOf(TDataItem)InitializeSource(IEnumerable<TDataItem>)LoadData(IEnumerable<TDataItem>)MoveCurrentTo(TDataItem)MoveCurrentToFirst()MoveCurrentToLast()MoveCurrentToNext()MoveCurrentToPosition(int)MoveCurrentToPrevious()MoveToFirstPage()MoveToLastPage()MoveToNextPage()MoveToPage(int)MoveToPreviousPage()OnCollectionChanged(NotifyCollectionChangedEventArgs)OnCurrentChanged(EventArgs)OnCurrentChanging(CancelEventArgs)OnNotifyPropertyChanged(PropertyChangedEventArgs)OnPageChanged()OnPageChanging(int)PassesFilter(TDataItem)ProcessCollectionChanged(NotifyCollectionChangedEventArgs)Refresh()RefreshOverride()SetCurrentPositionCore(int, bool, CurrentChangeReason)SetCurrentPositionCore(int, bool)VersionUpdateNeeded(NotifyCollectionChangedEventArgs)EventsCollectionChangedCurrentChangedCurrentChangingPageChangedPageChangingPropertyChanged
Not finding the help you need?
Contact Support