SPContentType Object Overview

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The following figure shows a high-level view of the structure of the SPContentTypeCollection object. This collection represents a collection of site or list content types, depending on the object it belongs to. When contained in an SPWeb object, the collection represents a collection of site content types; when contained in an SPList object, it represents a collection of list content types.

Using the SPContentTypeCollection Object

To return a read-only collection of all the content types defined on the specified site, as well as all the content types defined on parent sites, use the AvailableContentTypes property.

To return a collection of only the content types defined on the specific site itself, use the ContentTypes property.

To return a collection of the list content types on a list, use the ContentTypes property.

To determine whether a list supports multiple content types, use the AllowContentTypes property.

The various attributes of a content type are represented by the properties of the SPContentType object. If you make changes to a content type, either programmatically or through the user interface, Windows SharePoint Services stores those updates as entries within the Windows SharePoint Services database, rather than writing the changes back to the content type definition file. For more information, see Updating Content Types.

To propagate the changes you make to a site content type to its children, use the Update method. For more information, see Updating Child Content Types.

The SPFieldCollection contained in the SPContentType object represents the field references to the columns included in the content type. The SPFieldCollection in the SPContentType object enables developers to get a "merged view" of a column's attributes, as they are in that content type. Each SPField object in a content type represents all the attributes of a field, merged with those attributes that have been overridden in the field reference. Because of this, there is a one-to-one correlation between the items in the SPFieldLinkCollection and SPFieldCollection objects. For more information about the differences between fields and field references, see Fields and Field References.

See Also

Concepts

Introduction to Content Types

Content Type Definition Schema