WebPart.GetToolParts method
決定哪些工具組件顯示在工具窗格中的 Web 式網頁組件設計使用者介面,並會顯示的順序。
Namespace: Microsoft.SharePoint.WebPartPages
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Overridable Function GetToolParts As ToolPart()
'用途
Dim instance As WebPart
Dim returnValue As ToolPart()
returnValue = instance.GetToolParts()
public virtual ToolPart[] GetToolParts()
傳回值
Type: []
決定哪些工具組件會顯示在工具窗格的類型ToolPart陣列。如果網頁組件,實作一或多個自訂屬性不會覆寫GetToolParts方法,則基底類別方法會傳回WebPartToolPart類別的執行個體和CustomPropertyToolPart類別的執行個體。WebPartToolPart類別的執行個體,會顯示WebPart基底類別所提供的內容所使用的工具組件。CustomPropertyToolPart類別的執行個體會顯示使用自訂的網頁組件屬性的內建工具組件,只要是其中一種支援的工具組件類型的自訂屬性。支援的類型如下: String、 Boolean、 Integer、 DateTime或Enum。
備註
當建立自訂的網頁組件,包括自訂屬性,需要您必須覆寫GetToolParts方法,以指定的自訂工具組件] 清單中,將自訂的工具組件 ( ToolPart類別的實作),呈現工具窗格內。
Examples
下列程式碼範例會顯示覆寫的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;
}