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.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
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.
- type
- Type: Microsoft.SharePoint.SPFieldType
A SPFieldType value that specifies the type of field to create.
- 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.
- choices
- Type: System.Collections.Specialized.StringCollection
A System.Collections.Specialized.StringCollection object that contains choices for a Choice field.