SPFieldCollection.Add method (String, SPFieldType, Boolean, Boolean, StringCollection)

Creates a field in the collection based on the specified display name, field type, Boolean values for other field properties, and choices in the case of a Choice field.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Function Add ( _
    strDisplayName As String, _
    type As SPFieldType, _
    bRequired As Boolean, _
    bCompactName As Boolean, _
    choices As StringCollection _
) As String
'Usage
Dim instance As SPFieldCollection
Dim strDisplayName As String
Dim type As SPFieldType
Dim bRequired As Boolean
Dim bCompactName As Boolean
Dim choices As StringCollection
Dim returnValue As String

returnValue = instance.Add(strDisplayName, _
    type, bRequired, bCompactName, choices)
public string Add(
    string strDisplayName,
    SPFieldType type,
    bool bRequired,
    bool bCompactName,
    StringCollection choices
)

Parameters

  • strDisplayName
    Type: System.String

    A string that specifies the display name of the field.

  • bRequired
    Type: System.Boolean

    true to require that the field contain a value; otherwise, false.

  • bCompactName
    Type: System.Boolean

    true to compact the field name to eight characters; otherwise, false.

Return value

Type: System.String
A string that contains the internal name of the new field.

See also

Reference

SPFieldCollection class

SPFieldCollection members

Add overload

Microsoft.SharePoint namespace