FastBindingListT Class

Provides a generic list that is able to notify its consumer about changes and supports data binding.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
[SerializableAttribute]
public class FastBindingList<T> : FastLookupCollection<T>, 
	IBindingList, ICollection, IEnumerable, IList, ICancelAddNew, 
	IRaiseItemChangedEvents, IDisposable
Inheritance
Object    VirtualCollectionT    FastLookupCollectionT    FastBindingListT
Derived
Implements
ICollection, IEnumerable, IList, IBindingList, ICancelAddNew, IRaiseItemChangedEvents, IDisposable

Type Parameters

T
The type of elements in the list.

Remarks

Comparison with BindingListT

Incompatibility with BindingListT:

  Caution

Do not store elements in a FastBindingListT that may change their hash code while they are added to the collection. Finding such elements may fail even if CheckConsistency is . If hash code is derived from some identifier property or field, you can prepare a T instance by overriding the AddNewCore method or by subscribing the AddingNew event to make IBindingList.AddNew implementation work properly.

New features and improvements compared to BindingListT:

Constructors

FastBindingListT Initializes a new instance of the FastBindingListT class with a CircularListT internally.
FastBindingListT(IListT) Initializes a new instance of the FastBindingListT class with the specified list.

Properties

AllowEdit Gets or sets whether item properties can be edited in the list.
Default value: .
AllowNew Gets or sets whether new items can be added to the list by the AddNew method.
Default value: if the wrapped list is not read-only and T is a value type or has a parameterless constructor; otherwise, .
AllowRemove Gets or sets whether items can be removed from the list by the Remove, RemoveAt and Clear methods.
Default value: if the wrapped list is not read-only; otherwise, .
CanSetItem Gets whether an item can be set through the indexer.
The base implementation returns if IsReadOnly returns or when the wrapped collection is a one dimensional zero based array of T; otherwise, returns .
(Inherited from VirtualCollectionT)
CheckConsistency Gets or sets whether consistency of the stored items should be checked when items are get or set in the collection.
Default value: , if the FastLookupCollectionT was initialized by the default constructor; otherwise, as it was specified.
(Inherited from FastLookupCollectionT)
Count Gets the number of elements actually contained in the VirtualCollectionT.
The base implementation returns the Count property of the underlying collection.
(Inherited from VirtualCollectionT)
DisposeBehavior Specifies the strategy for treating the wrapped Items and the added values when this instance is disposed.
Default value: DisposeCollection.
IsReadOnly Gets whether the VirtualCollectionT is read-only. Affects the behavior of Add, Insert, Remove, RemoveAt and Clear methods.
The base implementation returns the IsReadOnly property of the underlying collection.
(Inherited from VirtualCollectionT)
IsSorted Gets whether the items in the list are sorted.
IsSortedCore Gets whether the list is sorted.
The base implementation returns .
Item Gets or sets the element at the specified index.
When read, calls the overridable GetItem method, and when set, calls the overridable SetItem method.
(Inherited from VirtualCollectionT)
Items Gets the wrapped underlying collection maintained by this VirtualCollectionT instance.
(Inherited from VirtualCollectionT)
PropertyDescriptors Gets the property descriptors of T.
RaiseListChangedEvents Gets or sets whether adding or removing items within the list raises ListChanged events.
Default value: .
SortDirectionCore Gets the direction of the sort.
The base implementation returns Ascending.
SortProperty Gets a PropertyDescriptor that is being used for sorting. Returns if the list is not sorted or when it is sorted by the values of T rather than by one of its properties.
SortPropertyCore Gets the property descriptor that is used for sorting the list if sorting, or if the list is not sorted or when it is sorted by the values of T rather than by one of its properties.
The base implementation returns .
SupportsChangeNotificationCore Gets whether ListChanged events are enabled.
The base implementation returns .
SupportsSearchingCore Gets whether the list supports searching.
The base implementation returns .
SupportsSortingCore Gets whether the list supports sorting.
The base implementation returns .

Methods

Add Adds an object to the end of the VirtualCollectionT.
Calls the overridable InsertItem method.
(Inherited from VirtualCollectionT)
AddIndexCore If overridden in a derived class, adds the PropertyDescriptors to the indices used for searching.
The base implementation does nothing.
AddNew Adds a new item to the collection.
AddNewCore Adds a new item to the collection.
ApplySort(ListSortDirection) Sorts the list by the values of T rather than one of its properties based on the specified direction.
ApplySort(PropertyDescriptor, ListSortDirection) Sorts the list based on the specified property and direction.
ApplySort(String, ListSortDirection) Sorts the list based on the specified propertyName and direction.
ApplySortCore If overridden in a derived class, sorts the items of the list.
The base implementation throws a NotSupportedException.
CancelNew Discards a pending new item added by the AddNew method.
Clear Removes all elements from the VirtualCollectionT.
Calls the overridable ClearItems method.
(Inherited from VirtualCollectionT)
ClearItems Removes all elements from the FastBindingListT.
(Overrides FastLookupCollectionTClearItems)
Contains Determines whether an element is in the VirtualCollectionT.
Calls the overridable ContainsItem method.
(Inherited from VirtualCollectionT)
ContainsItem Gets whether the specified item is in the VirtualCollectionT.
The base implementation calls the GetItemIndex method.
(Inherited from VirtualCollectionT)
CopyTo Copies the entire VirtualCollectionT to a compatible one-dimensional Array, starting at the specified arrayIndex of the target array.
Calls the overridable GetItem method for each index between zero and Count, excluding upper bound.
(Inherited from VirtualCollectionT)
Dispose Releases the list and removes both incoming and outgoing subscriptions.
Dispose(Boolean) Releases the resources used by this FastBindingListT instance.
EndNew Commits a pending new item of any position added by the AddNew method.
EndNew(Int32) Commits a pending new item added by the AddNew method.
Find(PropertyDescriptor, Object) Searches for the index of the item that has the specified property descriptor with the specified value.
Find(String, Object) Searches for the index of the item that has the specified property descriptor with the specified value.
FindCore Searches for the index of the item that has the specified property descriptor with the specified value.
The base implementation performs a linear search on the items.
GetEnumerator Returns an enumerator that iterates through the VirtualCollectionT.
The base implementation returns the enumerator of the underlying collection.
(Inherited from VirtualCollectionT)
GetItem Gets the element at the specified index.
(Overrides VirtualCollectionTGetItem(Int32))
GetItemIndex Gets the zero-based index of the first of the specified item within the FastLookupCollectionT.
(Inherited from FastLookupCollectionT)
IndexOf Searches for the specified object and returns the zero-based index of an occurrence within the entire VirtualCollectionT.
Calls the overridable GetItemIndex method.
(Inherited from VirtualCollectionT)
InnerListChanged Invalidates the internally stored index mapping. Call if the wrapped list that has been passed to the constructor has been changed explicitly.
(Inherited from FastLookupCollectionT)
Insert Inserts an element into the VirtualCollectionT at the specified index.
Calls the overridable InsertItem method.
(Inherited from VirtualCollectionT)
InsertItem Inserts an element into the FastBindingListT at the specified index.
(Overrides FastLookupCollectionTInsertItem(Int32, T))
OnAddingNew Raises the AddingNew event.
OnListChanged Raises the ListChanged event.
OnMapRebuilt Called after the internal index map has been rebuilt either when inconsistency has been detected or when InnerListChanged has been called.
(Overrides FastLookupCollectionTOnMapRebuilt)
Remove Removes one occurrence of a specific object from the VirtualCollectionT.
Calls the overridable RemoveItem method.
(Inherited from VirtualCollectionT)
RemoveAt Removes the element at the specified index of the VirtualCollectionT.
Calls the overridable RemoveItem method.
(Inherited from VirtualCollectionT)
RemoveIndexCore If overridden in a derived class, removes the PropertyDescriptors from the indices used for searching.
The base implementation does nothing.
RemoveItem Removes the first occurrence of item from the FastLookupCollectionT.
(Inherited from FastLookupCollectionT)
RemoveItemAt Removes the element at the specified index from the FastBindingListT.
(Overrides FastLookupCollectionTRemoveItemAt(Int32))
RemoveSort Removes any sort applied by the ApplySort overloads.
RemoveSortCore Removes any sort applied by the ApplySort overloads.
The base implementation throws a NotSupportedException.
ResetBindings Raises the ListChanged event of type Reset.
ResetItem Raises the ListChanged event of type ItemChanged at the specified position.
SetItem Replaces the item at the specified index.
(Overrides FastLookupCollectionTSetItem(Int32, T))

Events

AddingNew Occurs when a new item is added to the list by the AddNew method.
ListChanged Occurs when the list or an item in the list changes.

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
IndexOf Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOf Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IsNullOrEmpty Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
TryAdd Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddRange Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryClear Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryGetCount Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetElementAt Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryInsert Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertRange Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryRemove Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveAt Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveRange Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryReplaceRange Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TrySetElementAt Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)

See Also