Microsoft.SharePoint.WebCon ...


GroupedItemPicker Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class GroupedItemPicker
    Inherits Control
    Implements IPostBackDataHandler
Visual Basic (Usage)
Dim instance As GroupedItemPicker
C#
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
public sealed class GroupedItemPicker : Control, IPostBackDataHandler
Inheritance Hierarchy

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Tags :


Community Content

Adam Buenz - MVP
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


Tags : contentbug

Page view tracker