View 类

Specifies a list view.

继承层次结构

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.View

命名空间:  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 View _
    Inherits ClientObject
用法
Dim instance As View
public class View : ClientObject

备注

Use the DefaultView property of the List class to return the default view for a list, or the GetView() method to return a specified view. Use the GetViewFromUrl() method of the Web class to return a view for a list within a site, and use the View() property of the ViewFieldCollection class to get the parent view of the collection of view fields. Otherwise, use the Views property of the List 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 orders the items on the Tasks list of the specified site in descending alphabetic order.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class ViewExample
    {
        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;
            View targetView = collView.GetByTitle("All Tasks");
            string strQuery = "<OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy>";
            targetView.ViewQuery = strQuery;
            targetView.Update();

            clientContext.ExecuteQuery();

            Console.WriteLine("Tasks list ordered in descending alphabetic order.");
        }
    }
}

线程安全性

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

另请参阅

引用

View 成员

Microsoft.SharePoint.Client 命名空间