Back to Devexpress

SubDocument.FindAll(String, SearchOptions) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-dot-findall-x28-system-dot-string-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-searchoptions-x29.md

latest8.4 KB
Original Source

SubDocument.FindAll(String, SearchOptions) Method

Finds all text ranges that match the specified string in the specific part of the document (main body, text box, header, footer, comment, footnote, and endnote).

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange[] FindAll(
    string textToFind,
    SearchOptions options
)
vb
Function FindAll(
    textToFind As String,
    options As SearchOptions
) As DocumentRange()

Parameters

NameTypeDescription
textToFindString

A string, specifying the search text.

| | options | SearchOptions |

A SearchOptions enumeration specifying search options.

|

Returns

TypeDescription
DocumentRange[]

An array of DocumentRange objects representing matching text ranges.

|

Remarks

The following code snippet finds a word “letter”:

csharp
DocumentRange[] found = wordProcessor.Document.FindAll("letter", SearchOptions.WholeWord);
vb
Dim found As DocumentRange() = wordProcessor.Document.FindAll("letter", SearchOptions.WholeWord)

The SubDocument.FindAll method overload performs a search in a specific document part (main body, text box, header, footer, comment, footnote, or endnote). Iterate all document parts and call the SubDocument.FindAll method for each SubDocument to search throughout all document parts. Refer to the following example for a code snippet on how to iterate all sub-documents: How to Iterate through all Sub-documents in a Document

The following code snippets (auto-collected from DevExpress Examples) contain references to the FindAll(String, SearchOptions) method.

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-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L48

csharp
RichEditControl richEdit = e.Item.Tag as RichEditControl;
DocumentRange[] buttonWordRanges = richEdit.Document.FindAll("button", SearchOptions.None);
richEdit.Document.Selection = buttonWordRanges[0];

winforms-grid-richedit-highlight-search-results/CS/E4422/Form1.cs#L23

csharp
document.BeginUpdate();
DocumentRange[] ranges = document.FindAll(gridView1.FindFilterText, SearchOptions.None);
for (int i = 0; i < ranges.Length; i++) {

word-document-api-insert-inline-pictures/CS/Program.cs#L24

csharp
// Insert an image from a file.
DocumentRange rangeFound = document.FindAll("Visual Studio Magazine", SearchOptions.CaseSensitive)[0];
DocumentPosition pos = document.Paragraphs[document.Paragraphs.Get(rangeFound.End).Index + 2].Range.Start;

winforms-rich-edit-manage-tracked-changes/CS/XtraRichEdit_TrackChanges/Form1.cs#L36

csharp
//This modification is added an a new revision:
DocumentRange[] targetPhrases = richEditControl1.Document.FindAll("We measured hard disk space as a function of USB key space on an IBM PC Junior.", SearchOptions.None);
CharacterProperties characterProperties = richEditControl1.Document.BeginUpdateCharacters(targetPhrases[0]);

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/DocumentProperties.cs#L36

csharp
document.AppendText("A new value of MyBookmarkProperty is obtained from here: NEWVALUE!\n");
document.Bookmarks.Create(document.FindAll("NEWVALUE!", SearchOptions.CaseSensitive)[0], "bmOne");
document.AppendText("\nMyNumericProperty: ");

winforms-richeditcontrol-common-api/VB/RichEditAPISample/CodeExamples/RichEditControlActions.vb#L53

vb
Dim richEdit As RichEditControl = TryCast(e.Item.Tag, RichEditControl)
Dim buttonWordRanges() As DocumentRange = richEdit.Document.FindAll("button", SearchOptions.None)
richEdit.Document.Selection = buttonWordRanges(0)

winforms-grid-richedit-highlight-search-results/VB/E4422/Form1.vb#L26

vb
document.BeginUpdate()
Dim ranges As DocumentRange() = document.FindAll(gridView1.FindFilterText, SearchOptions.None)
For i As Integer = 0 To ranges.Length - 1

word-document-api-insert-inline-pictures/VB/Program.vb#L17

vb
' Insert an image from a file.
Dim rangeFound As DocumentRange = document.FindAll("Visual Studio Magazine", SearchOptions.CaseSensitive)(0)
Dim pos As DocumentPosition = document.Paragraphs(document.Paragraphs.Get(rangeFound.End).Index + 2).Range.Start

winforms-rich-edit-manage-tracked-changes/VB/XtraRichEdit_TrackChanges/Form1.vb#L30

vb
'This modification is added an a new revision:
Dim targetPhrases As DocumentRange() = richEditControl1.Document.FindAll("We measured hard disk space as a function of USB key space on an IBM PC Junior.", SearchOptions.None)
Dim characterProperties As CharacterProperties = richEditControl1.Document.BeginUpdateCharacters(targetPhrases(0))

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/DocumentProperties.vb#L33

vb
document.AppendText("A new value of MyBookmarkProperty is obtained from here: NEWVALUE!" & Global.Microsoft.VisualBasic.Constants.vbLf)
document.Bookmarks.Create(document.FindAll("NEWVALUE!", DevExpress.XtraRichEdit.API.Native.SearchOptions.CaseSensitive)(0), "bmOne")
document.AppendText(Global.Microsoft.VisualBasic.Constants.vbLf & "MyNumericProperty: ")

See Also

SubDocument Interface

SubDocument Members

DevExpress.XtraRichEdit.API.Native Namespace