共用方式為


SPWeb.ViewStyles property

取得網站的檢視樣式集合。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public ReadOnly Property ViewStyles As SPViewStyleCollection
    Get
'用途
Dim instance As SPWeb
Dim value As SPViewStyleCollection

value = instance.ViewStyles
public SPViewStyleCollection ViewStyles { get; }

Property value

Type: Microsoft.SharePoint.SPViewStyleCollection
SPViewStyleCollection 物件,表示檢視樣式。

Examples

下列程式碼範例使用ViewStyles屬性來傳回站台的檢視樣式的集合,它套用於新聞稿樣式 (15) 中指定的站台的清單的檢視。

Dim webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL")
    Dim vwStyles As SPViewStyleCollection = webSite.ViewStyles

    Dim vwStyle As SPViewStyle = vwStyles.StyleByID(15)
    Dim list As SPList = webSite.Lists("List_Name")
    Dim view As SPView = list.Views("View_Name")

    view.ApplyStyle(vwStyle)

    view.Update()
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
    SPViewStyleCollection collViewStyles = oWebsite.ViewStyles;
    SPViewStyle oViewStyle = collViewStyles.StyleByID(15);
    SPList oList = oWebsite.Lists["List_Name"];
    SPView oView = oList.Views["View_Name"];
    oView.ApplyStyle(oView);
    oView.Update();
}
注意事項注意事項

某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects

請參閱

參照

SPWeb class

SPWeb members

Microsoft.SharePoint namespace