Share via


ListField Object

SharePoint Designer Developer Reference

Contains information about the fields that make up a List object.

Remarks

The fields of a list define the columns that appear in the list and present information about the items in the list. The ListField object is a base class that defines the common members used by the different types of fields in Office SharePoint Designer lists.

Use ListFields(Index), where Index is either the name of the field or its position within the collection, to return a single ListField object. The following example displays the names of all fields in the current list. If the Web site contains no lists, a message is displayed to the user.

Visual Basic for Applications
Sub ListAllFields()
'Displays the name of fields in the current list
    Dim objApp As Application
    Dim objField As ListField
    Dim strType As String
    Set objApp = Application
    If Not ActiveWeb.Lists Is Nothing Then
        For Each objField In objApp.ActiveWeb.Lists.Item(0).Fields
            If strType = "" Then
                'Create new string
                strType = objField.Name & vbCr
            Else
                'Add next field name to string
                strType = strType & objField.Name & vbCr
            End If
        Next objField
        MsgBox "The names of the fields in this list are: " & _
                vbCr & strType
    Else
        'Otherwise display message to user
        MsgBox "The current web site contains no lists."
    End If
End Sub

See Also