Contents
How to add a content type to a list definition?
To add a content type to a list definition, you add a ContentTypes element to the list schema. The ContentTypes element contains a collection of ContentTypeRef elements.
You can use the SharePoint Foundation object model to add content types to an existing list. Use the Lists property to get a collection of lists for the site on which the list is located. Declare a variable of type SPList, and set it equal to the object in the site list collection that represents the list.
What does the contenttypes element do in SharePoint?
The ContentTypes element contains a collection of ContentTypeRef elements. Each ContentTypeRef element specifies a site content type that SharePoint Foundation should copy locally to the list, as a list content type, whenever a user creates a new list of the specified type.
How to add a spcontenttype object to a list in SharePoint?
Use the Add method to add the SPContentType object to the list content type collection. When you add a site content type to a list using the object model, SharePoint Foundation automatically adds any columns that the content type contains that are not already on the list.
When do you add a site content type to a library?
When you add a site content type to a list or library, it is called a list content type. The list content type is a child of the site content type from which it was created. It inherits all the attributes of its parent site content type, such as its document template, read-only setting, workflows, and columns.
Can a new content type be added to a parent content type?
The new column would not be added to the site content type from which the list content type derives, nor would any other changes carry over. Changes to a derived content type are never pushed up to the parent content type. However, a list content type can be affected by changes that are made to its parent.