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

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

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

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

Gets the groups.

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

The groups.

Implements: ICollectionView<TDataItem>.Groups

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.

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>

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

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()
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
C#
public virtual void EnsureDescriptors()

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

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

bool

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>

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

IEnumerator<TDataItem>

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

object

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

int

Indexes the of.

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

The item.

Returns:

int

Implements: IReadOnlyCollection<TDataItem>.IndexOf(TDataItem)

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

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()

C#
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs
C#
protected virtual void OnCurrentChanged(EventArgs args)
Parameters:argsEventArgs
C#
protected virtual void OnCurrentChanging(CancelEventArgs args)
Parameters:argsCancelEventArgs

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

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

Refreshes this data view.

C#
public virtual void Refresh()

Implements: ICollectionView<TDataItem>.Refresh()

C#
protected virtual void RefreshOverride()
C#
protected bool SetCurrentPositionCore(int newPosition, bool forceNotify, CurrentChangeReason reason)
Parameters:newPositionintforceNotifyboolreasonCurrentChangeReasonReturns:

bool

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

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

bool

Events

C#
public event EventHandler CurrentChanged

Implements: ICollectionView<TDataItem>.CurrentChanged

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

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