Back to Devexpress

Field.ResultRange Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-field-55a736e6.md

latest3.6 KB
Original Source

Field.ResultRange Property

Returns the range that contains the field result.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange ResultRange { get; }
vb
ReadOnly Property ResultRange As DocumentRange

Property Value

TypeDescription
DocumentRange

The document range the field result occupies.

|

Example

The code sample below checks all field results and inserts “Empty Value!” if the field result is empty:

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

using (var wordProcessor = new RichEditDocumentServer()) {
    Document document = wordProcessor.Document;
    foreach (Field field in document.Fields) {
        string strResult = document.GetText(field.ResultRange);

        if (strResult == "") {
            document.InsertText(field.ResultRange.Start, "Empty Value!");
        }
    }
}
vb
``Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports System.Drawing

Using wordProcessor = New RichEditDocumentServer()
    Dim document As Document = wordProcessor.Document
    For Each field As Field In document.Fields
        Dim strResult As String = document.GetText(field.ResultRange)

        If strResult = "" Then
            document.InsertText(field.ResultRange.Start, "Empty Value!")
        End If
    Next field
End Using

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ResultRange 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.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Export.cs#L109

csharp
options.AllowExtendingDocumentRange = false;
foreach (Paragraph par in document.Paragraphs.Get(item.ResultRange)) {
    plainText += document.GetText(par.Range, options);

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Export.vb#L97

vb
options.AllowExtendingDocumentRange = False
For Each par As DevExpress.XtraRichEdit.API.Native.Paragraph In document.Paragraphs.[Get](item.ResultRange)
    plainText += document.GetText(par.Range, options)

See Also

Field Interface

Field Members

DevExpress.XtraRichEdit.API.Native Namespace