Version

SortedTaskFieldsCollection Class

Provides sorting support for the Tasks collection.
Syntax
'Declaration
 
Public Class SortedTaskFieldsCollection 
public class SortedTaskFieldsCollection 
Remarks

The SortedTaskFieldsCollection provides a way to specify the sort order of the root Tasks collection and the respective Tasks collections of each root task and their descendants. Tasks are sorted with respect to the other members in the same collection, i.e., tasks which belong to different Tasks collections are never compared.

The SortedTaskFieldsCollection exposes methods typically seen in collection classes such as Add, AddRange, Remove and Clear. To sort on one field, the developer adds one member to the collection. To sort on multiple fields, the developer adds multiple members to the collection; in this scenario, the first member of the collection provides the first criteria to be evaluated, awith the second and subsequent mebers determining additional criteria. When the comparison is performed, this collection is iterated and the value of the corresponding task property for that collection member is compared for each task. If the result of the comparison for that iteration yields equality, iteration is allowed to continue, until either one of the field comparisons yields inequality, or all members of the SortedTaskFieldsCollection have been evaluated.

The AddRange method provides a way to specify multiple sort fields as one atomic operation, so that only one property change notification is sent, after the entire collection has been populated. This can improve performance since the collections will only be sorted once, rather than n times where n is the number of elements in the SortedTaskFieldsCollection.

Adding or inserting a member into the collection when a member with the same value for the Key property already exists will result in the repositioning of the existing instance to the new index. The collection automatically prevents duplicate values from existing in the collection.

The SortableTaskField enumeration provides a constant for each of the Task properties on which the Tasks collection can be sorted. Certain properties are intentionally omitted from this enumeration as their values cannot be sorted in any meaningful way. To sort by a custom TaskColumn, use the Key of that column. Comparer property provides a way to define custom sorting behavior for Tasks; assigning a valid IComparer(Of Task) implementation to this property overrides the contents of the collection, providing the developer with complete control over the sorting.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also