WebPart.GetToolParts 方法
确定哪些工具部件中显示的工具窗格中的基于 Web 的 Web 部件设计用户界面,并在其中显示的顺序。
命名空间: Microsoft.SharePoint.WebPartPages
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Overridable Function GetToolParts As ToolPart()
用法
Dim instance As WebPart
Dim returnValue As ToolPart()
returnValue = instance.GetToolParts()
public virtual ToolPart[] GetToolParts()
返回值
类型:[]
确定哪些工具部件将显示在工具窗格的类型ToolPart数组。如果实现的一个或多个自定义属性的 Web 部件不重写GetToolParts方法,基类方法将返回WebPartToolPart类的实例和CustomPropertyToolPart类的实例。WebPartToolPart类的实例显示由WebPart基类的属性使用工具的部件。CustomPropertyToolPart类的实例显示内置的工具部件用于处理自定义 Web 部件的属性,只要自定义属性是一个支持该工具部件的类型。支持的类型包括: String、 Boolean、 Integer、 DateTime或Enum。
备注
当创建自定义 Web 部件包含在工具窗格内呈现需要自定义工具部件 ( ToolPart类的实现),您必须覆盖GetToolParts方法,以指定的自定义工具部件列表中的自定义属性。
示例
下面的代码示例演示重写的GetToolParts方法。
' Gets the custom tool parts for this Web Part by overriding the
' GetToolParts method of the WebPart base class. You must implement
' custom tool parts in a separate class that derives from
' Microsoft.SharePoint.WebPartPages.ToolPart.
' Returns an array of references to ToolPart objects.
Public Overrides Function GetToolParts()As ToolPart()
Dim toolParts(2) As ToolPart
Dim wptp As WebPartToolPart = New WebPartToolPart()
Dim custom As CustomPropertyToolPart = New CustomPropertyToolPart()
toolparts(0) = wptp
toolparts(1) = custom
Return toolparts
End Function
/// <summary>
/// Gets the custom tool parts for this Web Part by overriding the
/// GetToolParts method of the WebPart base class. You must implement
/// custom tool parts in a separate class that derives from
/// Microsoft.SharePoint.WebPartPages.ToolPart.
/// </summary>
/// <returns>An array of references to ToolPart objects.</returns>
public override ToolPart[] GetToolParts()
{
ToolPart[] toolparts = new ToolPart[2];
WebPartToolPart wptp = new WebPartToolPart();
CustomPropertyToolPart custom = new CustomPropertyToolPart();
toolparts[0] = wptp;
toolparts[1] = custom;
return toolparts;
}