PickerItem Class
Represents a reusable module for items consumed in a picker object such as the GroupedItemPicker control.
Namespace:
Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
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.
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
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
- 6/3/2010
- Adam Buenz - MVP