FieldTCEntryLevel Property

Gets or sets the level of the entry.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string EntryLevel { get; set; }

Property Value

Type: String
Examples
Shows how to insert a TOC field and filter which TC fields end up as entries.
public void FieldTocEntryIdentifier()
{
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.StartBookmark("MyBookmark");

    // Insert a list num field using a document builder
    FieldToc fieldToc = (FieldToc)builder.InsertField(FieldType.FieldTOC, true);
    fieldToc.EntryIdentifier = "A";
    fieldToc.EntryLevelRange = "1-3";

    builder.InsertBreak(BreakType.PageBreak);

    // These two entries will appear in the table
    InsertTocEntry(builder, "TC field 1", "A", "1");
    InsertTocEntry(builder, "TC field 2", "A", "2");

    // These two entries will be omitted because of an incorrect type identifier
    InsertTocEntry(builder, "TC field 3", "B", "1");

    // ...and an out-of-range entry level
    InsertTocEntry(builder, "TC field 4", "A", "5");

    Assert.AreEqual(" TOC  \\f A \\l 1-3", fieldToc.GetFieldCode());

    doc.UpdateFields();
    doc.Save(ArtifactsDir + "Field.TC.docx");
}

/// <summary>
/// Insert a table of contents entry via a document builder.
/// </summary>
public void InsertTocEntry(DocumentBuilder builder, string text, string typeIdentifier, string entryLevel)
{
    FieldTC fieldTc = (FieldTC)builder.InsertField(FieldType.FieldTOCEntry, true);
    fieldTc.OmitPageNumber = true;
    fieldTc.Text = text;
    fieldTc.TypeIdentifier = typeIdentifier;
    fieldTc.EntryLevel = entryLevel;
}
See Also