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

'' This sample demonstrates how to create a simple bullet list.
'' See the NumberedList sample for how to create a numbered list.
Public Class Bullets
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()
        Dim pars = doc.Body.Paragraphs
        pars.Add("Example of a bullet list with three levels:")

        '' A ListTemplate Is used to make paragraphs part of a list
        Dim myListTemplate = doc.ListTemplates.Add(BuiltInListTemplateId.BulletDefault, "myListTemplate")

        '' Action to add a list item
        Dim addListItem As Action(Of String, Integer) =
            Sub(t_, l_)

                Dim p_ = pars.Add(t_)
                '' This makes a paragraph a list item
                p_.ListFormat.Template = myListTemplate
                '' Set the item's nesting level (first level is 0):
                p_.ListFormat.LevelNumber = l_
                '' This ensures item spacing consistent with MS Word
                p_.Style = doc.Styles(BuiltInStyleId.ListParagraph)
            End Sub

        '' Build a bullet list with 3 levels of nesting
        addListItem("Bullet item 1", 0)
        addListItem("Bullet item 2", 0)
        addListItem("Bullet item 3", 0)
        addListItem("Nested bullet item 1", 1)
        addListItem("Nested bullet item 2", 1)
        addListItem("Double nested bullet item 1", 2)
        addListItem("Double nested bullet item 2", 2)
        addListItem("Nested bullet item 3", 1)
        addListItem("Bullet item 4", 0)

        '' Done:
        Return doc
    End Function
End Class