This topic has not yet been rated - Rate this topic

GroupedItemPicker Class

Represents a set of possible items to choose and selected items with selection controls. The control is rendered as an optional set drop-down list box to select a group, and a set of two select boxes, with buttons to select items.

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.GroupedItemPicker

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class GroupedItemPicker : Control, 
	IPostBackDataHandler

The first box contains the set of possible items to select. The second box contains the set of items that have been chosen. Buttons allow an item to be moved from one set to the other.

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
GroupedItemPicker
Description
 
The Microsoft.SharePoint.WebControls.GroupedItemPicker class inherits from System.Web.UI.Control to support ASP.NET server control development as well as the System.Web.UI.IPostBackDataHandler interface in order to support automatic loading of PostBack data. Ascetically, the GroupedItemPicker control from a user interface perspective is represented by two ListBox like controls with add/remove buttons to move contents between the two boxes. 
 
It should be noted strongly typed ListBox objects are not used; rather a combination of literal HTML is used to provide the interface.
The GroupedItemPicker class functions by using the Microsoft.SharePoint.WebControls.PickerItem class to represent its available items. The use of this class to strongly type items allows related metadata display information to be used in the control, most importantly:
 
PickerItem.DescriptionHtml – the description can either be a direct string literal, or this property can be used to signify a selection description that is an HTML string. In order to use a direct string literal, the GroupedItemPicker.AddItem method is used, for HTML the GroupedItemPicker.AddItemHtml method is used.
 
PickerItem.Group – the group specifies the categorization string that the item is a member of
 
Usage Scenario
 
The primary usage of the GroupedItemPicker within the shipped software is for management of objects that are categorized into groups, such as when selecting site columns to add to a list, or similarly for management of content types on lists. Both of these actions make use of the GroupedItemPicker control because when stored in SharePoint they are arranged by type.
 
While it has heavy representation within the shipped software, it is also possible to use the control within custom development since it is a customary control.
 
In the below example, MyClass is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class and its CreateChildControls method is being overridden. Following, a new GroupedItemPicker object is being created. Firstly dumping values that might be present be invoking the GroupdItemPicker.Clear method, subsequently we are adding an item to the control through the GroupdItemPicker.AddItem method to signify we are passing in a string for description, not an HTML literal. Lastly, the control is added to the current instance control collection for future rendering.
 
C# Code Example
 
public class MyClass : WebPart
    {
        protected override void CreateChildControls()
        {
            GroupedItemPicker picker = new GroupedItemPicker();
            picker.Clear();
            picker.AddItem("ID", "Adams Item", " Adams Description", " Adams Group");
            Controls.Add(picker);
            base.CreateChildControls();
        }
    }
 
VB.NET Code Example
 
Public Class [MyClass]
    Inherits WebPart
    Protected Overloads Overrides Sub CreateChildControls()
        Dim picker As New GroupedItemPicker()
        picker.Clear()
        picker.AddItem("ID", "Adams Item", " Adams Description", " Adams Group")
        Controls.Add(picker)
        MyBase.CreateChildControls()
    End Sub
End Class
 
Adam Buenz
SharePoint Services MVP - http://www.sharepointsecurity.com