Back to Devexpress

ContentControlRepeatingSection Interface

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-c0f53683.md

latest4.8 KB
Original Source

ContentControlRepeatingSection Interface

Repeating section content control.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public interface ContentControlRepeatingSection :
    ContentControlBase
vb
Public Interface ContentControlRepeatingSection
    Inherits ContentControlBase

Remarks

Note

The ContentControlCollection does not contain methods to create a repeating section content control in code.

The SubDocument.ContentControls property returns all content controls in a document. Use the ContentControlBase.ControlType property to determine the content control type.

The code sample below retrieves all building block galleries in a document:

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer()) {

    wordProcessor.LoadDocument("Content Controls.docx");
    Document document = wordProcessor.Document;
    var contentControls = document.ContentControls;
    var firstParagraph = document.Paragraphs[0];
    for (var i = 0; i < contentControls.Count; i++)
    {
        if (firstParagraph.Range.Contains(contentControls[i].Range.Start) && contentControls[i].ControlType == ContentControlType.RepeatingSection)
        {
            ContentControlRepeatingSection repeatingSection = (ContentControlRepeatingSection)contentControls[i];
            repeatingSection.Color = Color.Crimson;
            break;
        }
        wordProcessor.SaveDocument("Content Controls.docx", DocumentFormat.Docx);
    }
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor = New RichEditDocumentServer()

  wordProcessor.LoadDocument("Content Controls.docx")
  Dim document As Document = wordProcessor.Document
  Dim contentControls = document.ContentControls
  Dim firstParagraph = document.Paragraphs(0)
  For i = 0 To contentControls.Count - 1
    If firstParagraph.Range.Contains(contentControls(i).Range.Start) AndAlso contentControls(i).ControlType = ContentControlType.RepeatingSection Then
      Dim repeatingSection As ContentControlRepeatingSection = CType(contentControls(i), ContentControlRepeatingSection)
      repeatingSection.Color = Color.Crimson
      Exit For
    End If
    wordProcessor.SaveDocument("Content Controls.docx", DocumentFormat.Docx)
  Next i
End Using

The ContentControlCollection.Remove method allows you to remove specific content control. You can also specify whether to keep control’s contents when the controls is removed.

The code sample below removes all building block galleries from the document:

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer()) {
    Document document = wordProcessor.Document;
    var contentControls = document.ContentControls;

    for (var i = 0; i < contentControls.Count; i++)
    {
        if (contentControls[i].ControlType == ContentControlType.RepeatingSection)
        {
            contentControls.Remove(contentControls[i], true);
        }
    }
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor = New RichEditDocumentServer()
  Dim document As Document = wordProcessor.Document
  Dim contentControls = document.ContentControls

  Dim i = 0
  Do While i < contentControls.Count
    If contentControls(i).ControlType = ContentControlType.RepeatingSection Then
      contentControls.Remove(contentControls(i), True)
    End If
    i += 1
  Loop
End Using

See Also

ContentControlRepeatingSection Members

DevExpress.XtraRichEdit.API.Native Namespace