# Paragraph Numbering

Learn how to number paragraphs in your Word document using DsWord in easy steps.

## Content

DsWord allows you to specify paragraph numbering using the [ListTemplate](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ListTemplate.html) class which can be accessed using [ListTemplates](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.DocumentBase.ListTemplates.html) property of the **DocumentBase** class.

## Get Paragraph Numbering

To get the paragraph numbering:

1. Access a paragraph from the paragraph collection using [Paragraphs](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.RangeBase.Paragraphs.html) property of the **RangeBase** class.
2. Get the list formatting specified for the paragraph using [ListFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Paragraph.ListFormat.html) property of the **Paragraph** class.
3. Access list template of the paragraph using [Template](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ListFormat.Template.html) property of the [ListFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ListFormat.html) class.
4. Get the name of the list template using [Name](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ListTemplate.Name.html) property of the **ListTemplate** class.
5. Display the paragraph numbering on the console.

    ```csharp
    //Get paragraph numbering
    ParagraphCollection pars = doc.Body.Sections.First.GetRange().Paragraphs;
    Console.WriteLine("Numbering template for the first paragraph: " + 
        pars[0].ListFormat.Template.Name);
    ```

## Set Paragraph Numbering

To set the paragraph numbering:

1. Access the collection of list templates using **ListTemplates** property of the GcWordDocument class.
2. Add a new list template to the collection of list templates using [Add](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ListTemplateCollection.Add.html) method of the [ListTemplateCollection](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ListTemplateCollection.html) class.
3. Access a paragraph from the paragraph collection using **Paragraphs** property of the RangeBase class.
4. Get the list formatting specified for the paragraph using **ListFormat** property of the Paragraph class.
5. Set list template of the paragraph using **Template** property of the **ListFormat** class.

    ```csharp
    //Set paragraph numbering
    ParagraphCollection pars = doc.Body.Sections.First.GetRange().Paragraphs;
    // A ListTemplate is used to assign ListFormat/numbering to paragraphs
    ListTemplate myListTemplate = doc.ListTemplates.Add(
        BuiltInListTemplateId.NumberArabicParenthesis, "myListTemplate");
    //Set the ListFormat for the paragraphs
    Paragraph p1 = pars[0];
    p1.ListFormat.Template = myListTemplate;
    Paragraph p2 = pars[1];
    p2.ListFormat.Template = myListTemplate;
    ```

For more information on how to implement paragraph numbering using DsWord, see [DsWord sample browser](https://developer.mescius.com/documents-api-word/demos/).