Problems with class TextSearchResults and FindAll method.
Hi, im having some problems using TextSearchResults and FindAll. Here is part of my code:
private List<Syncfusion.Windows.Controls.RichTextBoxAdv.TextSearchResult> searchResults = new List<Syncfusion.Windows.Controls.RichTextBoxAdv.TextSearchResult>();
foreach (var term in searchTerms)
{
string normalizedTerm = RemoveDiacritics(term);
string regexPattern = GenerateDiacriticInsensitiveRegex(normalizedTerm);
TextSearchResults results = richTextBoxAdv.FindAll(new Regex(regexPattern, RegexOptions.IgnoreCase), FindOptions.None);
if (results != null && results.Count > 0)
{
for (int i = 0; i < results.Count; i++) {
var result = results[i]; // Acceder al resultado por índice
if (result.Start != null && result.End != null)
{
searchResults.Add(result);
TextPosition start = result.Start;
TextPosition end = result.End;
richTextBoxAdv.Selection.Select(start, end);
richTextBoxAdv.Selection.CharacterFormat.HighlightColor = HighlightColor.Turquoise;
}
}
}
}
What I'm doing is I'm trying to search for more than one search term in my document. First, I use findAll with a regex to look for my first searchTerm, then I save those results in my List named searchResults. You can see the contents of this list in the first iteration in one of the attached images. As you can see in said image, I have all the information properly inserted in my List (start, end and text).
The problem comes when we get into the second iteration. When I do exactly the same process, the results I previously inserted in my searchResultsList are now gone and only the latter remains. As you can see in the second image.
I've tested it and the previous results disappear when executing the findAll method for the second term.
Why is this happening? Is this a bug or a mistake on my part?
Thank you in advance, Jose Antonio.
Attachment: sfImages_eb1de912.zip
Jose Antonio, we attempted to reproduce the issue you
reported using the details you provided, but we were unable to do so.
In our testing, we loaded the document and searched all occurence for three
texts using a Regex pattern. All three words were successfully found and
highlighted, and the details of each search result were stored in the
collections without missing.
We have attached a sample application and a video illustration of our attempts.
If you continue to experience the issue, please modify the application provided
to demonstrate the problem on our side. This will assist us in reproducing the
issue, validating it, and providing you with a solution as soon as possible.
Attachment: SfRichTextBoxAdv_FindAll_4c4eaf3c.zip
Hi Kalaivannan,
I've reproduced my issue in your sample application without making any modifications. I've also attached a video illustrating the problem.
As you can see, when I start adding occurrences of the second term to my list, the values of the previous term— which I had already stored—disappear. Finding and highlighting have never been the issue, but I need to retain the information in searchList to use it in another method.
Thanks again,
Jose Antonio
Attachment: RE_SfRichTextBoxAdv_FindAll_4c4eaf3c_40ac0320.zip
Jose Antonio, we have reproduced the reported issue where
the `TextSearchResults` of a previous search are missing when finding
all occurrences of a subsequent text in the `SfRichTextBoxAdv`
control.
SfRichTextBoxAdv Behaviour: This control operates at the UI level and can only
find all occurrences of one text string at a time. When a new search is
initiated for another text, the results of the previous search are disposed of
because they should not be retained. Subsequently, a fresh search operation is
performed for the new text and shows the latest search results in the search panel.
If the previous results were also maintained while searching for new text, both
the previous and current search results would be shown in the search panel.
In your implementation, you're using the backend code of this functionality.
This means that when you search for a new text, the previous results are
cleared due to the functionality of the SfRichTextBoxAdv. Once these results
are disposed of in the SfRichTextBoxAdv control, they are also removed from
your collection.
Solution: If you plan to use these search results for other
functionalities, we recommend processing them immediately before initiating a
new search. This approach will ensure that the data is utilized before being
cleared.
- 3 Replies
- 2 Participants
-
JA Jose Antonio
- Mar 24, 2025 04:10 PM UTC
- Mar 26, 2025 01:07 PM UTC