次の方法で共有


ViewCollection Class

Specifies a collection of list views.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ClientObjectCollection
      Microsoft.SharePoint.Client.ClientObjectCollection<View>
        Microsoft.SharePoint.Client.ViewCollection

Namespace:  Microsoft.SharePoint.Client
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
<ScriptTypeAttribute("SP.ViewCollection", ServerTypeId := "{03c5d7a9-9541-4482-9919-ca0cccf565a0}")> _
Public Class ViewCollection _
    Inherits ClientObjectCollection(Of View)
'Usage
Dim instance As ViewCollection
[ScriptTypeAttribute("SP.ViewCollection", ServerTypeId = "{03c5d7a9-9541-4482-9919-ca0cccf565a0}")]
public class ViewCollection : ClientObjectCollection<View>

Examples

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ViewCollection Members

Microsoft.SharePoint.Client Namespace