Compartilhar via


SPViewFieldCollection Class

The SPViewFieldCollection class represents the collection of fields returned in a view.

System.Object

   Microsoft.SharePoint.SPBaseCollection

      Microsoft.SharePoint.SPViewFieldCollection

Public Methods

The following table shows the public methods of the SPViewFieldCollection class and a brief description of each.

Name Description
Add(Microsoft.SharePoint.SPField) Adds the specified field to the collection.
Add(String) Adds the field with the specified name to the collection.
Delete(Microsoft.SharePoint.SPField) Deletes the specified field from the collection.
Delete(String) Deletes from the collection the field with the specified name.
DeleteAll Deletes all the view fields from the collection.
Exists Returns a Boolean value that indicates whether the specified view field exists.
Explicit(Int32) Verifies whether the field at the specified index in the collection is explicitly declared in the view definition.
Explicit(String) Verifies whether the field with the specified name in the collection is explicitly declared in the view definition.
ToStringCollection Loads the names of the view fields into a StringCollection object

Public Properties

The following table shows the public properties of the SPViewFieldCollection class, the data type of each property, and a brief description of each.

Name Data Type Description
Count Int32 Gets the number of view fields in the collection.
Item String Gets the internal name of the view field at the specified index in the collection.
SchemaXml String Gets the schema that specifies the view fields in the collection.
View Microsoft.SharePoint.SPView Gets the parent view for the collection.

Thread Safety

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

Remarks

Use the ViewFields property of the SPQuery, SPView, or SPViewStyle class to return an SPViewFieldCollection object that represents the collection of view fields for a query, view, or view style. Use an indexer to return a single view field from the collection. For example, if the collection is assigned to a variable named myViewFields, use myViewFields[index] in C#, or myViewFields(index) in Visual Basic .NET, where index is the index number of the field in the collection.

Example

The following code example removes the Modified field from the specified view of an Announcements list and adds the Expires field to the view.

This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.

Requirements

Namespace: Microsoft.SharePoint

Platforms: Microsoft Windows Server 2003

Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)

Security: Code Access Security