KGy SOFT

SortableBindingListT Class

KGy SOFT Core Libraries Help
Provides a sortable generic list that is able to notify its consumer about changes and supports data binding.
See the Remarks section for details.
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 SortableBindingList<T> : FastBindingList<T>

Type Parameters

T
The type of elements in the list.

The SortableBindingListT type exposes the following members.

Constructors

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

  NameDescription
Public propertyAllowEdit
Gets or sets whether item properties can be edited in the list.
Default value: .
(Inherited from FastBindingListT.)
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, .
(Inherited from FastBindingListT.)
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, .
(Inherited from FastBindingListT.)
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.
(Inherited from FastBindingListT.)
Protected propertyIsSortedCore
Gets whether the list is sorted.
(Overrides FastBindingListTIsSortedCore.)
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.
(Inherited from FastBindingListT.)
Public propertyRaiseListChangedEvents
Gets or sets whether adding or removing items within the list raises ListChanged events.
Default value: .
(Inherited from FastBindingListT.)
Protected propertySortDirectionCore
Gets the direction of the sort.
If the list is not sorted (that is, when IsSorted returns ), this property returns Ascending.
(Overrides FastBindingListTSortDirectionCore.)
Public propertySortOnChange
Gets or sets whether the SortableBindingListT should be immediately re-sorted when an item changes or a new item is added.
Default value: .
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.
(Inherited from FastBindingListT.)
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.
(Overrides FastBindingListTSortPropertyCore.)
Protected propertySupportsChangeNotificationCore
Gets whether ListChanged events are enabled.
The base implementation returns .
(Inherited from FastBindingListT.)
Protected propertySupportsSearchingCore
Gets whether the list supports searching.
The base implementation returns .
(Inherited from FastBindingListT.)
Protected propertySupportsSortingCore
Gets whether the list supports sorting.
The SortableBindingListT returns .
(Overrides FastBindingListTSupportsSortingCore.)
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.
(Inherited from FastBindingListT.)
Public methodAddNew
Adds a new item to the collection.
(Inherited from FastBindingListT.)
Protected methodAddNewCore
Adds a new item to the collection.
(Inherited from FastBindingListT.)
Public methodApplySort(ListSortDirection)
Sorts the list by the values of T rather than one of its properties based on the specified direction.
(Inherited from FastBindingListT.)
Public methodApplySort(PropertyDescriptor, ListSortDirection)
Sorts the list based on the specified property and direction.
(Inherited from FastBindingListT.)
Public methodApplySort(String, ListSortDirection)
Sorts the list based on the specified propertyName and direction.
(Inherited from FastBindingListT.)
Protected methodApplySortCore
Sorts the items of the list.
(Overrides FastBindingListTApplySortCore(PropertyDescriptor, ListSortDirection).)
Public methodCancelNew
Discards a pending new item added by the AddNew method.
(Overrides FastBindingListTCancelNew(Int32).)
Public methodClear (Inherited from VirtualCollectionT.)
Protected methodClearItems
Removes all elements from the SortableBindingListT.
(Overrides FastBindingListTClearItems.)
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.
(Inherited from FastBindingListT.)
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources.
(Inherited from FastBindingListT.)
Protected methodEndNew
Commits a pending new item of any position added by the AddNew method.
(Overrides FastBindingListTEndNew.)
Public methodEndNew(Int32)
Commits a pending new item added by the AddNew method.
(Overrides FastBindingListTEndNew(Int32).)
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.
(Inherited from FastBindingListT.)
Public methodFind(String, Object)
Searches for the index of the item that has the specified property descriptor with the specified value.
(Inherited from FastBindingListT.)
Protected methodFindCore
Searches for the index of the item that has the specified property descriptor with the specified value.
(Overrides FastBindingListTFindCore(PropertyDescriptor, Object).)
Public methodGetEnumerator
Returns an enumerator that iterates through the SortableBindingListT.
(Overrides VirtualCollectionTGetEnumerator.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetItem
Gets the element at the specified index.
(Overrides FastBindingListTGetItem(Int32).)
Protected methodGetItemIndex (Overrides FastLookupCollectionTGetItemIndex(T).)
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.
(Overrides FastLookupCollectionTInnerListChanged.)
Public methodInsert (Inherited from VirtualCollectionT.)
Protected methodInsertItem
Inserts an element into the SortableBindingListT at the specified index.
(Overrides FastBindingListTInsertItem(Int32, T).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnAddingNew
Raises the AddingNew event.
(Inherited from FastBindingListT.)
Protected methodOnListChanged
Raises the ListChanged event.
(Overrides FastBindingListTOnListChanged(ListChangedEventArgs).)
Protected methodOnMapRebuilt
Called after the internal index map has been rebuilt either when inconsistency has been detected or when InnerListChanged has been called.
(Inherited from FastBindingListT.)
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.
(Inherited from FastBindingListT.)
Protected methodRemoveItem
Removes the element at the specified index from the SortableBindingListT.
(Overrides FastBindingListTRemoveItem(Int32).)
Public methodRemoveSort
Removes any sort applied by the ApplySort overloads.
(Inherited from FastBindingListT.)
Protected methodRemoveSortCore
Removes any sort applied by the ApplySortCore method.
(Overrides FastBindingListTRemoveSortCore.)
Public methodResetBindings
Raises the ListChanged event of type Reset.
(Inherited from FastBindingListT.)
Public methodResetItem
Raises the ListChanged event of type ItemChanged at the specified position.
(Inherited from FastBindingListT.)
Protected methodSetItem
Replaces the item at the specified index.
(Overrides FastBindingListTSetItem(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.
(Inherited from FastBindingListT.)
Public eventListChanged
Occurs when the list or an item in the list changes.
(Inherited from FastBindingListT.)
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 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.)
Top
Remarks

The SortableBindingListT class provides a sortable view for the wrapped list specified in the constructor.

To sort the list the ApplySort overloads can be used. As sorting is supported via the standard IBindingList interface, binding a SortableBindingListT instance to UI controls (eg. to a grid) enables sorting automatically in several GUI frameworks.

Note Note
Sorting does not change the order of the elements in the wrapped underlying collection. When items are added while IsSorted returns , then new items are added to the end of the underlying list.
See Also

Reference