KGy SOFT

FastBindingListT Class

KGy SOFT Core Libraries Help
Provides a generic list that is able to notify its consumer about changes and supports data binding.
See the Remarks section for the differences compared to the BindingListT class.
Inheritance Hierarchy

SystemObject
  KGySoft.Collections.ObjectModelVirtualCollectionT
    KGySoft.Collections.ObjectModelFastLookupCollectionT
      KGySoft.ComponentModelFastBindingListT
        KGySoft.ComponentModelSortableBindingListT

Namespace:  KGySoft.ComponentModel
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0-rc.1
Syntax

[SerializableAttribute]
public class FastBindingList<T> : FastLookupCollection<T>, 
	IBindingList, IList, ICollection, IEnumerable, ICancelAddNew, 
	IRaiseItemChangedEvents, IDisposable

Type Parameters

T
The type of elements in the list.

The FastBindingListT type exposes the following members.

Constructors

  NameDescription
Public methodFastBindingListT
Initializes a new instance of the FastBindingListT class with a CircularListT internally.
Public methodFastBindingListT(IListT)
Initializes a new instance of the FastBindingListT class with the specified list.
Top
Properties

  NameDescription
Public propertyAllowEdit
Gets or sets whether item properties can be edited in the list.
Default value: .
Public propertyAllowNew
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, .
Public propertyAllowRemove
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, .
Protected propertyCanSetItem
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.)
Public propertyCheckConsistency
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.)
Public propertyCount (Inherited from VirtualCollectionT.)
Public propertyIsReadOnly
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.)
Public propertyIsSorted
Gets whether the items in the list are sorted.
Protected propertyIsSortedCore
Gets whether the list is sorted.
The base implementation returns .
Public propertyItem
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.)
Protected propertyItems (Inherited from VirtualCollectionT.)
Protected propertyPropertyDescriptors
Gets the property descriptors of T.
Public propertyRaiseListChangedEvents
Gets or sets whether adding or removing items within the list raises ListChanged events.
Default value: .
Protected propertySortDirectionCore
Gets the direction of the sort.
The base implementation returns Ascending.
Public propertySortProperty
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.
Protected propertySortPropertyCore
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 .
Protected propertySupportsChangeNotificationCore
Gets whether ListChanged events are enabled.
The base implementation returns .
Protected propertySupportsSearchingCore
Gets whether the list supports searching.
The base implementation returns .
Protected propertySupportsSortingCore
Gets whether the list supports sorting.
The base implementation returns .
Top
Methods

  NameDescription
Public methodAdd (Inherited from VirtualCollectionT.)
Protected methodAddIndexCore
If overridden in a derived class, adds the PropertyDescriptors to the indices used for searching.
The base implementation does nothing.
Public methodAddNew
Adds a new item to the collection.
Protected methodAddNewCore
Adds a new item to the collection.
Public methodApplySort(ListSortDirection)
Sorts the list by the values of T rather than one of its properties based on the specified direction.
Public methodApplySort(PropertyDescriptor, ListSortDirection)
Sorts the list based on the specified property and direction.
Public methodApplySort(String, ListSortDirection)
Sorts the list based on the specified propertyName and direction.
Protected methodApplySortCore
If overridden in a derived class, sorts the items of the list.
The base implementation throws a NotSupportedException.
Public methodCancelNew
Discards a pending new item added by the AddNew method.
Public methodClear (Inherited from VirtualCollectionT.)
Protected methodClearItems
Removes all elements from the FastBindingListT.
(Overrides FastLookupCollectionTClearItems.)
Public methodContains (Inherited from VirtualCollectionT.)
Protected methodContainsItem (Inherited from VirtualCollectionT.)
Public methodCopyTo
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.)
Public methodDispose
Releases the list and removes both incoming and outgoing subscriptions.
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Protected methodEndNew
Commits a pending new item of any position added by the AddNew method.
Public methodEndNew(Int32)
Commits a pending new item added by the AddNew method.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFind(PropertyDescriptor, Object)
Searches for the index of the item that has the specified property descriptor with the specified value.
Public methodFind(String, Object)
Searches for the index of the item that has the specified property descriptor with the specified value.
Protected methodFindCore
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.
Public methodGetEnumerator
Returns an enumerator that iterates through the VirtualCollectionT.
The base implementation returns the enumerator of the underlying collection.
(Inherited from VirtualCollectionT.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetItem
Gets the element at the specified index.
(Overrides FastLookupCollectionTGetItem(Int32).)
Protected methodGetItemIndex (Inherited from FastLookupCollectionT.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf
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.)
Public methodInnerListChanged
Rebuilds the internally stored index mapping. Call if CheckConsistency is   and the internally wrapped list has been changed explicitly.
(Inherited from FastLookupCollectionT.)
Public methodInsert (Inherited from VirtualCollectionT.)
Protected methodInsertItem
Inserts an element into the FastBindingListT at the specified index.
(Overrides FastLookupCollectionTInsertItem(Int32, T).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnAddingNew
Raises the AddingNew event.
Protected methodOnListChanged
Raises the ListChanged event.
Protected methodOnMapRebuilt
Called after the internal index map has been rebuilt either when inconsistency has been detected or when InnerListChanged has been called.
(Overrides FastLookupCollectionTOnMapRebuilt.)
Public methodRemove (Inherited from VirtualCollectionT.)
Public methodRemoveAt (Inherited from VirtualCollectionT.)
Protected methodRemoveIndexCore
If overridden in a derived class, removes the PropertyDescriptors from the indices used for searching.
The base implementation does nothing.
Protected methodRemoveItem
Removes the element at the specified index from the FastBindingListT.
(Overrides FastLookupCollectionTRemoveItem(Int32).)
Public methodRemoveSort
Removes any sort applied by the ApplySort overloads.
Protected methodRemoveSortCore
Removes any sort applied by the ApplySort overloads.
The base implementation throws a NotSupportedException.
Public methodResetBindings
Raises the ListChanged event of type Reset.
Public methodResetItem
Raises the ListChanged event of type ItemChanged at the specified position.
Protected methodSetItem
Replaces the item at the specified index.
(Overrides FastLookupCollectionTSetItem(Int32, T).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events

  NameDescription
Public eventAddingNew
Occurs when a new item is added to the list by the AddNew method.
Public eventListChanged
Occurs when the list or an item in the list changes.
Top
Extension Methods

  NameDescription
Public Extension MethodConvert(Type, CultureInfo)Overloaded.
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.)
Public Extension MethodCode exampleConvertTTarget(CultureInfo)Overloaded.
Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions.)
Public Extension MethodIn (Defined by ObjectExtensions.)
Public Extension MethodIndexOf(FuncObject, Boolean)Overloaded.
Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions.)
Public Extension MethodIndexOf(Object)Overloaded.
Searches for an element in the source enumeration.
(Defined by EnumerableExtensions.)
Public Extension MethodIsNullOrEmpty
Determines whether the specified source is  or empty (has no elements).
(Defined by EnumerableExtensions.)
Public Extension MethodTryAdd
Tries to add the specified item to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryAddRange
Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryClear
Tries to remove all elements from the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryConvert(Type, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvert(Type, CultureInfo, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvertTTarget(TTarget)Overloaded.
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.)
Public Extension MethodTryConvertTTarget(CultureInfo, TTarget)Overloaded.
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.)
Public Extension MethodTryGetElementAt
Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryInsert
Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryInsertRange
Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemove
Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveAt
Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveRange
Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions.)
Public Extension MethodTryReplaceRange
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.)
Public Extension MethodTrySetElementAt
Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions.)
Top
Remarks

Note Note
FastBindingListT is mainly compatible with BindingListT but has a better performance than that because element lookup in FastBindingListT is an O(1) operation. In contrast, element lookup in BindingListT is an O(n) operation, which makes BindingList<T>.AddNew and BindingList<T>.ListChanged invocation (when an element is changed) slow because they call the Collection{T}.IndexOf method to determine the position of the added or changed element.

Comparison with BindingListT

Incompatibility with BindingListT:

New features and improvements compared to BindingListT:

Tip Tip
FastBindingListT does not implement sorting. See the derived SortableBindingListT class for an IBindingList implementation with sorting support.
See Also

Reference