共用方式為


SPWeb.ViewStyles Property

Gets the collection of view styles for the website.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public ReadOnly Property ViewStyles As SPViewStyleCollection
    Get
'Usage
Dim instance As SPWeb
Dim value As SPViewStyleCollection

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

Property Value

Type: Microsoft.SharePoint.SPViewStyleCollection
An SPViewStyleCollection object that represents the view styles.

Examples

The following code example uses the ViewStyles property to return the collection of view styles for a site and it applies a Newsletter style (15) to a view for a list in the specified site.

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();
}

Note

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

See Also

Reference

SPWeb Class

SPWeb Members

Microsoft.SharePoint Namespace