Share via


ListFieldChoice Object

SharePoint Designer Developer Reference

Contains information about the choice field. The choice field allows the user to select from a specified number of options by providing a drop-down list or option (radio) buttons in the list.

Remarks

Use ListFields(Index), where Index is the name or ordinal position of a field of type FieldTypeChoice, to return a single ListFieldChoice object.

Use the Add method to add a field of type FieldTypeChoice to the ListFields collection. The following example adds a new field named NewChoiceField of type FieldTypeChoice to the ListFields collection. Use the AddChoice method to add choices to the list. Use the ClearChoices method to clear the choices from the list.

Visual Basic for Applications
Sub DisplayChoice()
'Display choice
    Dim objApp As Application
    Dim objLstFlds As listFields
    Dim objFldChoice As ListFieldChoice
    Dim strName As String
    Set objApp = Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    strName = "NewChoiceField"
    'Add new field of type FieldTypeChoice to list
    objLstFlds.Add Name:=strName, Description:="New Choice value Field", _
                   Type:=FieldTypeChoice, Required:=True
    MsgBox "A new Field named " & strName & " was added to the list " & _
           objApp.ActiveWeb.Lists.Item(0).Name & "."
End Sub

See Also