SPViewStyleCollection 类

代表SPViewStyle对象的集合。

继承层次结构

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.SPBaseCollection
      Microsoft.SharePoint.SPViewStyleCollection

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Class SPViewStyleCollection _
    Inherits SPBaseCollection
用法
Dim instance As SPViewStyleCollection
public class SPViewStyleCollection : SPBaseCollection

备注

\\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\XML\VWSTYLES.XML中定义视图样式。

使用SPWeb类的ViewStyles属性可返回网站的视图样式的集合。使用索引器从集合中返回的单个视图样式。例如,如果集合分配给名为collViewStyles的变量中,使用 C# 中的collViewStyles[index]或collViewStyles(index)在 Visual Basic 中,其中index是集合中的视图样式的索引号。

示例

下面的代码示例适用于指定的网站中列表的视图的 Boxed 样式 (13)。

Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim site As SPWeb = siteCollection.AllWebs("Site_Name")
Dim vwStyles As SPViewStyleCollection = site.ViewStyles

Dim vwStyle As SPViewStyle = vwStyles.StyleByID(13)

Dim list As SPList = site.Lists("List_Name")
Dim view As SPView = list.Views("View_Name")

view.ApplyStyle(vwStyle)

view.Update()
SPSite oSiteCollection = SPContext.Current.Site;
    using(SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
    {
        SPViewStyleCollection collViewStyles = oWebsite.ViewStyles;

        SPViewStyle oViewStyle = collViewStyles.StyleByID(13);
        SPList oList = oWebsite.Lists["List_Name"];
        SPView oView = oList.Views["View_Name"];
        oView.ApplyStyle(oViewStyle);
        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.

线程安全性

该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。

另请参阅

引用

SPViewStyleCollection 成员

Microsoft.SharePoint 命名空间