ViewCollection 类
Specifies a collection of list views.
继承层次结构
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<View>
Microsoft.SharePoint.Client.ViewCollection
命名空间: Microsoft.SharePoint.Client
程序集: Microsoft.SharePoint.Client.Silverlight(位于 Microsoft.SharePoint.Client.Silverlight.dll 中); Microsoft.SharePoint.Client.Phone(位于 Microsoft.SharePoint.Client.Phone.dll 中) Microsoft.SharePoint.Client(位于 Microsoft.SharePoint.Client.dll 中)
语法
声明
Public Class ViewCollection _
Inherits ClientObjectCollection(Of View)
用法
Dim instance As ViewCollection
public class ViewCollection : ClientObjectCollection<View>
备注
Use the Views property of either the List or View class to return the collection of views for a list or the parent collection of views for a view. Use an indexer to return a single view from a collection of views. For example, if the collection is assigned to a variable named collViews, use collViews[index] in C#, or collViews(index) in Visual Basic, where index is the index number of the view in the collection, the name of the view, or the GUID for the view.
示例
This code example adds a new view to the Tasks list of the specified site, and displays the list’s current views.
using System;
using Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointFoundation.Samples
{
class ViewCollectionExample
{
static void Main()
{
string siteUrl = "http://MyServer/sites/MySiteCollection";
ClientContext clientContext = new ClientContext(siteUrl);
Web site = clientContext.Web;
List targetList = site.Lists.GetByTitle("Tasks");
ViewCollection collView = targetList.Views;
ViewCreationInformation viewInfo = new ViewCreationInformation();
viewInfo.Title = "MyView";
collView.Add(viewInfo);
clientContext.Load(collView);
clientContext.ExecuteQuery();
Console.WriteLine("Tasks list current views:\n\n");
foreach (View oneView in collView)
Console.WriteLine(oneView.Title);
}
}
}
线程安全性
该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。