SPWeb.ViewStyles 属性
Gets the collection of view styles for the website.
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public ReadOnly Property ViewStyles As SPViewStyleCollection
Get
用法
Dim instance As SPWeb
Dim value As SPViewStyleCollection
value = instance.ViewStyles
public SPViewStyleCollection ViewStyles { get; }
属性值
类型:Microsoft.SharePoint.SPViewStyleCollection
An SPViewStyleCollection object that represents the view styles.
示例
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();
}
备注
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.