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

Provides access to a list's items. Most reads use the data view when enabled; the explicit non-generic CopyTo(Array, int) implementation and updates operate on the underlying list source.

Definition

Namespace:Telerik.WinControls.UI

Assembly:Telerik.WinControls.UI.dll

Syntax:

C#
public class RadListDataItemCollection : IList, ICollection, IEnumerable

Inheritance: objectRadListDataItemCollection

Derived Classes: RadCheckedListDataItemCollection

Implements: ICollectionIEnumerableIList

Constructors

Initializes a collection backed by the specified data layer and owned by the list element.

C#
public RadListDataItemCollection(ListDataLayer dataLayer, RadListElement ownerListElement)
Parameters:dataLayerListDataLayer

The data layer that supplies the items and their current view.

ownerListElementRadListElement

The list element that receives item-change notifications.

Properties

Gets the number of items in the current view, or in the source when this collection does not use a view.

C#
public int Count { get; }

Implements: ICollection.Count

Gets the first item in the collection's current sequence, or null when the collection is empty.

C#
public RadListDataItem First { get; }

Gets whether the underlying list source is read-only.

C#
public bool IsReadOnly { get; }

Implements: IList.IsReadOnly

Gets the last item in the collection's current sequence, or null when the collection is empty.

C#
public RadListDataItem Last { get; }

Gets the data layer that supplies this collection's source and view.

C#
public ListDataLayer Owner { get; }

Gets the list element that owns this collection and coordinates item changes.

C#
public RadListElement OwnerListElement { get; }

Gets an item from the current view, or replaces the item at the corresponding index in the underlying list source.

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

The item index.

Property Value:

The item at the specified index.

When the view is sorted or filtered, the setter still treats index as a source index rather than a view index. The owner can cancel a replacement.

Methods

Adds an item to the list, unless the owner cancels the pending addition. For an unbound source the supplied instance is added; for a bound source a new item is created and its text is copied.

C#
public virtual void Add(RadListDataItem item)
Parameters:itemRadListDataItem

The item whose text or instance is used for the addition.

Creates an item with the specified display text and adds it to the list.

C#
public virtual void Add(string itemText)
Parameters:itemTextstring

The text to display for the new item.

Adds a batch of items to the underlying list source. The owner receives a cancellable batch notification before the items are added. When the owner accepts the batch, the input is enumerated again to add the items.

C#
public void AddRange(IEnumerable<RadListDataItem> range)
Parameters:rangeIEnumerable<RadListDataItem>

The items to add.

Exceptions: ArgumentNullException

range is null.

The input must support repeated enumeration; a single-use sequence can produce the batch notification without adding its items. If the owner cancels the notification, the input is enumerated only to build that notification and no items are added.

Creates one RadListDataItem for each supplied string and adds the items as a batch.

C#
public virtual void AddRange(IEnumerable<string> textStrings)
Parameters:textStringsIEnumerable<string>

The display text for the items to add.

Exceptions: ArgumentNullException

textStrings is null.

Removes all items, detaches them from the list, and clears the active and selected item state.

C#
public void Clear()

Implements: IList.Clear()

Determines whether the item is present in the current view, or in the source when this collection does not use a view.

C#
public bool Contains(RadListDataItem item)
Parameters:itemRadListDataItem

The item to find.

Returns:

bool

true if the item is present; otherwise, false.

Determines whether an item in the collection's current sequence has text equal to the specified value using invariant-culture, case-sensitive comparison.

C#
public bool Contains(string text)
Parameters:textstring

The text.

Returns:

bool

true if a matching item is present; otherwise, false.

Copies items to the destination array using arrayIndex as both the collection index and destination index. Items before that collection index are not copied.

C#
public void CopyTo(RadListDataItem[] array, int arrayIndex)
Parameters:arrayRadListDataItem[]

The destination array.

arrayIndexint

The first collection and destination-array index to copy.

Returns an enumerator over the current view, or over the source when this collection does not use a view.

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

IEnumerator<RadListDataItem>

An enumerator for the items exposed by this collection.

Gets the item's index in the collection's exposed sequence, which is the data view when enabled and otherwise the source.

C#
public int IndexOf(RadListDataItem item)
Parameters:itemRadListDataItem

The item to locate.

Returns:

int

The zero-based index, or -1 if the item is not in the exposed sequence.

Finds the first item whose Text matches the specified text using invariant-culture, case-sensitive comparison.

C#
public int IndexOf(string text)
Parameters:textstring

The text to find.

Returns:

int

The zero-based index in the collection's current sequence, or -1 if no item matches.

Inserts an item into the underlying list source at the specified index. The owner can cancel the pending addition.

C#
public void Insert(int index, RadListDataItem item)
Parameters:indexint

The index at which to insert the item.

itemRadListDataItem

The item to insert.

Removes the specified item unless the owner cancels the operation.

C#
public bool Remove(RadListDataItem item)
Parameters:itemRadListDataItem

The item to remove.

Returns:

bool

true if the item was removed; otherwise, false.

Removes the item at the specified collection index, unless the owner cancels the pending removal.

C#
public void RemoveAt(int index)
Parameters:indexint

The index of the item to remove.

Implements: IList.RemoveAt(int)