Skip to main content

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TC

  • 2 minutes to read

Non-MailMerge field

{ TC “entry text” [ switches ] }

Specifies the text and page number for a table of contents entry, which is used by a TOC.

The TC field supports the following switches:

Switch Description
\f identifier The type of items collected in a particular contents list. Use a unique type identifier for each type of list. This switch is required for including into corresponding TOC.
\l “level number” The level of the TC entry. If no level is specified, level 1 is assumed.
using (var wordProcessor = new RichEditDocumentServer()) {
wordProcessor.LoadDocument("Documents//Table of Contents.docx");
int j = 1;

// Mark every chapter title in the document by the TC field
for (int i = 0; i < wordProcessor.Document.Paragraphs.Count; i++) {
    string var = wordProcessor.Document.GetText(wordProcessor.Document.Paragraphs[i].Range);

    if (var.Contains("CHAPTER ")) {
        Field field = wordProcessor.Document.Fields.Create(wordProcessor.Document.Paragraphs[i].Range.Start, String.Format("TC {0} \\f bvz ", j));
        wordProcessor.Document.Fields.Update();
        j++;
    }
  } 
}