Partager via


SPWebPartCollection Class

The SPWebPartCollection class represents a collection of Web Parts.

System.Object

   System.Collections.CollectionBase

      Microsoft.SharePoint.SPWebPartCollection

Public Methods

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

Name Description
Add(Microsoft.SharePoint.WebPartPages.ListViewWebPart) Adds the specified ListView Web Part to the collection.
Add(Microsoft.SharePoint.WebPartPages.WebPart) Adds the specified Web Part to the collection.
Add(String) Adds a Web Part to the collection based on the specified Web Part definition file.
CacheInvalidate Invalidates the cache for a Web Part, including the output and part caches.
Contains Returns a Boolean value that indicates whether the specified Web Part is contained in the collection.
CopyTo Copies the elements of the collection to an array of Web Part objects, starting at the specified array index.
Delete Deletes the Web Part with the specified GUID from the collection.
DeleteAllPersonalizations() Deletes all personalizations by all users from the collection.
DeleteAllPersonalizations(Int32) Deletes all personalizations by the user with the specified ID from the collection.
DeletePersonalizations Deletes personalizations of the Web Part with the specified GUID.
GetEnumerator Returns an enumerator to iterate through the collection.
IndexOf Returns the collection index of the specified Web Part.
SaveChanges Saves changes made to a single Web Part.

Public Properties

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

Name Data Type Description
IsSynchronized Boolean Gets a Boolean value that indicates whether access to the collection is synchronized or thread-safe.
Item(Int32) Microsoft.SharePoint.WebPartPages.WebPart Gets the Web Part object at the specified index in the collection.
Item(System.Guid) Microsoft.SharePoint.WebPartPages.WebPart Gets the Web Part object with the specified GUID from the collection.
ServerRelativeUrl String Gets the server-relative URL of the collection.
Storage Microsoft.SharePoint.WebPartPages.Storage Gets the storage mode that was used to create the collection.
SyncRoot Object Gets an object that is used to synchronize access to the collection.
Web Microsoft.SharePoint.SPWeb Gets the parent Web site of 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.

Requirements

Namespace: Microsoft.SharePoint

Platforms: Microsoft Windows Server 2003

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

Security: Code Access Security