共用方式為


SPView.ApplyStyle method

對檢視套用指定的樣式。

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

Syntax

'宣告
Public Sub ApplyStyle ( _
    viewStyle As SPViewStyle _
)
'用途
Dim instance As SPView
Dim viewStyle As SPViewStyle

instance.ApplyStyle(viewStyle)
public void ApplyStyle(
    SPViewStyle viewStyle
)

參數

備註

呼叫Update方法,以在資料庫中儲存這些變更。

StyleByID(Int32)方法會傳回的 Id 和Microsoft SharePoint Foundation的原始安裝中所包含的檢視樣式名稱。

Examples

下列程式碼範例會套用至指定的清單中目前的網站集合之網站的所有項目檢視方塊化樣式。

Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim site As SPWeb = siteCollection.AllWebs("Site_Name")
Dim list As SPList = site.Lists("List_Name")
Dim view As SPView = list.Views("All Items")
Dim intBoxed As Integer = 13

view.ApplyStyle(site.ViewStyles.StyleByID(intBoxed))

view.Update()
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
{
    SPList oList = oWebsite.Lists["List_Name"];
    SPView oView = oList.Views["All Items"];
    int intBoxed = 13;

    oView.ApplyStyle(oWebsite.ViewStyles.StyleByID(intBoxed));

    oView.Update();
}
注意事項注意事項

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

請參閱

參照

SPView class

SPView members

Microsoft.SharePoint namespace