ListNumFieldOpts.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.Globalization
Imports GrapeCity.Documents.Word
Imports GrapeCity.Documents.Word.Fields

'' This sample shows how to add a LISTNUM (List Number) field to a Word document,
'' and specify its options.
Public Class ListNumFieldOpts
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()

        Dim listName As String = "MyList"
        doc.ListTemplates.Add(BuiltInListTemplateId.OutlineLegal, listName)

        Dim options = New ListNumFieldOptions(doc) With {
            .Name = listName,
            .Level = 1
        }

        Dim table As Table = doc.Body.AddTable(
            New String()() {
                New String() {"Step", "Description"},
                New String() {Nothing, "Open the Settings menu."},
                New String() {Nothing, "Select ""Preferences"" from the list."},
                New String() {Nothing, "Click ""Save"" to apply changes."}
            }, doc.Styles(BuiltInStyleId.GridTable1Light))

        table.Format.StyleOptions = table.Format.StyleOptions Or TableStyleOptions.FirstRow

        table(1, 0).GetRange().Paragraphs.First.GetRange().ComplexFields.Add(options)
        table(2, 0).GetRange().Paragraphs.First.GetRange().ComplexFields.Add(options)
        table(3, 0).GetRange().Paragraphs.First.GetRange().ComplexFields.Add(options)

        doc.UpdateFields(New GrapeCity.Documents.Word.Layout.WordLayoutSettings() With {
            .FontCollection = Util.FontCollection,
            .Culture = CultureInfo.GetCultureInfo("en-US")
        })

        Return doc
    End Function
End Class