Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

SPContentType Constructor

Windows SharePoint Services 3

Initializes a new instance of the SPContentType class.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Public Sub New ( _
	parentContentType As SPContentType, _
	collection As SPContentTypeCollection, _
	name As String _
Dim parentContentType As SPContentType
Dim collection As SPContentTypeCollection
Dim name As String

Dim instance As New SPContentType(parentContentType, _
	collection, name)


Type: Microsoft.SharePoint.SPContentType
An SPContentType object from which this content type will be derived.
Type: Microsoft.SharePoint.SPContentTypeCollection
An SPContentTypeCollection object that represents the collection to which this content type will be added.
Type: System.String
A String object that contains the name of the content type. This string is set as the value of the new content type Name property.

The collection object that you pass as the second argument to the constructor is used to obtain certain initial values for properties of the new content type. However, the new content type is not automatically added to the collection. You must do that yourself in a subsequent call to the Add(SPContentType) method.

The following example creates a content type that is derived from the “Item” type and then adds the new type to the site collection.

Dim site As SPSite = New SPSite("http://localhost")
Dim web As SPWeb = site.OpenWeb()

' Get a reference to the site content type collection.
Dim contentTypes As SPContentTypeCollection = web.ContentTypes

' Create a Customer content type derived from the Item content type.
Dim contentType As SPContentType = New SPContentType(contentTypes("Item"), contentTypes, "Customer")

' Add the content type to the site collection.
contentType = contentTypes.Add(contentType)

' Clean up.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.