SPView.ApplyStyle 方法
将指定的样式应用到视图。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
声明
Public Sub ApplyStyle ( _
viewStyle As SPViewStyle _
)
用法
Dim instance As SPView
Dim viewStyle As SPViewStyle
instance.ApplyStyle(viewStyle)
public void ApplyStyle(
SPViewStyle viewStyle
)
viewStyle
类型:Microsoft.SharePoint.SPViewStyle要应用的视图样式。
调用Update方法将这些更改保存在数据库中。
StyleByID(Int32)方法返回的 Id 和Microsoft SharePoint Foundation的原始安装中所包含的视图样式的名称。
下面的代码示例将盒装样式应用到指定列表当前网站集的网站中的所有项目视图。
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。