Skip to main content

TextFragmentOptions.AllowExtendingDocumentRange Property

Specifies whether or not a document range may be extended to include the entire field instead of only part of a field.

Namespace: DevExpress.XtraRichEdit.API.Native.Implementation

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

public bool AllowExtendingDocumentRange { get; set; }

Property Value

Type Description
Boolean

true to permit extending the document range; otherwise false.

Example

This code snippet finds the first table of contents which is built upon Heading styles using the TOC field and converts it to plain text paragraph by paragraph. The SubDocument.GetText method overload is used for this purpose. It allows you to set the TextFragmentOptions.AllowExtendingDocumentRange option to false to not include the entire TOC when exporting the first paragraph.

View Example

using DevExpress.XtraRichEdit.API.Native.Implementation;
using DevExpress.XtraEditors;

document.LoadDocument("SampleTOC.docx");
string plainText = String.Empty;

foreach (Field item in document.Fields) {
    string fieldCode = document.GetText(item.CodeRange);
    string[] fieldParts = fieldCode.Split(' ');
    if (fieldParts[0].Trim() == "TOC" && fieldParts[1].Trim() == "\\h") {
        TextFragmentOptions options = 
            new TextFragmentOptions();
        options.AllowExtendingDocumentRange = false;
        foreach (Paragraph par in document.Paragraphs.Get(item.ResultRange)) {
            plainText += document.GetText(par.Range, options);
            plainText += Environment.NewLine;
        }
    }
}

XtraMessageBox.SmartTextWrap = false;
XtraMessageBox.Show(plainText);

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AllowExtendingDocumentRange property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also