How to: Reference a Column in a Content Type
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.
You can specify column references in a content type definition, so that each time a user provisions a content type of that type, the content type references the columns by default. Content type definitions can be included in Features. For more information, see Working with Features.
After a user adds a content type to a site, you can reference columns in that content type by using the Windows SharePoint Services object model.
If you want to reference a column in a content type definition that is part of a Feature, you must add the necessary XML element to the content type definition. Then, when a user provisions a content type of that type, the column is referenced in the content type by default.
To reference a column to a content type definition
If you make changes to a column reference on a content type that has been provisioned, Windows SharePoint Services never writes those changes back to the XML column definition itself. Instead, Windows SharePoint Services stores updates made to column references as entries within the Windows SharePoint Services database. For more information, see Updating Site Columns.
You can use the Windows SharePoint Services object model to programmatically reference columns in provisioned content types.
To reference a column in a provisioned content type
Use the Add method to add a column reference to the content type.
Columns are included in content types by reference, rather than directly. For more information, see Fields and Field References.
The Fields property returns an SPFieldCollection object. Each SPField in this collection represents a "merged view" of the base column definition and any overwritten properties specified in the column reference in the content type. Because of this, you cannot add columns directly to this collection. Attempting to do so results in an error.