0 out of 1 rated this helpful - Rate this topic

PickerItem Class

Represents a reusable module for items consumed in a picker object such as the GroupedItemPicker control.

System.Object
  Microsoft.SharePoint.WebControls.PickerItem

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
public sealed class PickerItem

Representing picker items as PickerItem objects allows strongly typed collections to be built that support standard enumeration. The most notable use of this class is for internal picker controls for strongly typed collections of picker items. Since the class is sealed it is not possible to extend the class with supplementary values, and since it is read-only none of the properties can be set for object creation.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
PickerItem
Description

The Microsoft.SharePoint.WebControls.PickerItem class represents a reusable module for items consumed in a picker object, such as the Microsoft.SharePoint.WebControls.GroupedItemPicker control. Representing picker items as PickerItem objects allows strongly typed collections to be built that support customary enumeration. 

There are 5 private fields exposed as public properties, however they should not be considered “backing stores” or “backing fields” since they have no setters provided. The lack of setters should be noted since the paradigm of private fields having indirect access approaches is commonly implemented since it provides a mechanism where malformed input values can be protected against.

PickerItem.DescriptionHtml – String representation of the HTML description

PickerItem.Group – String representation of the item group

PickerItem.Id – String representation of the item id

PickerItem.Name – String representation of the item name

PickerItem.Order – Integer representation of the sorting order

The Usage Scenario

The most notable use of the PickerItem class is for internal picker controls for strongly typed collections of picker items. Since the class is sealed, it is not possible to extend the class with supplementary values, and due to the lack of setters none of the properties can be set for object creation.

In the below, I am demonstrating basic collection iteration over a PickerItem typed collection.

C# Code Example

private List<PickerItem> collection;
private void IterateAndWritePickerCollection(TextWriter writer)
{
foreach (var item in collection)
{
writer.Write(item.Id);
writer.Write(item.Name);
}
}

Visual Basic .NET Code Example

Private collection As List(Of PickerItem)
Private Sub IterateAndWritePickerCollection(ByVal writer As TextWriter)
For Each item As var In collection
writer.Write(item.Id)
writer.Write(item.Name)
Next

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com