Enforce visibility of text range

HI there, I replace multiple instances of texts in multi-page documents. 

I want to show the process to the user, that is, I want to enforce the visibility of the text range to be replaced.

I have text start and end positions, how to scroll to them?

like  treeView.ensureVisible.

Thanks.


11 Replies 1 reply marked as answer

KG Kalaivannan Ganesan Syncfusion Team December 13, 2021 12:27 PM UTC

Hi Gorog,

Thanks for contacting Syncfusion support.

You can implement an extension class to retrieve the scrollbars of SfRichTextBoxAdv using GetTemplateChild method. In extension class, you can add your own APIs to perform the scrolling.

Please refer to the below KB for more details
https://www.syncfusion.com/kb/7771/how-to-scroll-sfrichtextboxadv-programmatically

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan
 



GG Gyorgy Gorog December 13, 2021 02:44 PM UTC

Kalaivannan, thenk for the update.

I am aware of the scrolling possibility, 

But how do I map a TextSearchResult position to a scrollbar position? 

Thanks




KG Kalaivannan Ganesan Syncfusion Team December 14, 2021 06:31 PM UTC

Hi Gorog,

Thanks for the update.

The Text can be searched and replaced by the build-in API’s Find and Replace methods. While replacing the respective text, the selection would be moved to the respective text position and created a sample to demonstrate the same which can be downloaded from the below location.  

Sample Link :
https://www.syncfusion.com/downloads/support/forum/171123/ze/SfRichTextBoxAdv_Replace258908368

Please use the below link to know more about the find and replace in SfRichTextBoxAdv:
https://help.syncfusion.com/wpf/richtextbox/find-and-replace

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan 



GG Gyorgy Gorog December 15, 2021 08:15 PM UTC

Kalaivannan, your example works. However the reason it shows the change is because it replaces one text range at a time.

I have a TextSearchResults collection and replacing one-by-one the selection does not show up, only after all replacements have been done.

TextSearchResults entities = GetTemplateEntities();

if ( entities.Count == 0 ) return;
for ( int entityNo = entities.Count-1; entityNo >= 0; entityNo--)
    {
  TextSearchResult entity = entities[entityNo];
        RichTextBoxAdv.Selection.Select(entity.Start, entity.End);
....
}
Last selection shows up when method is leaved.
InvalidateArrange() won't help either.



KG Kalaivannan Ganesan Syncfusion Team December 16, 2021 02:10 PM UTC

Hi Gyorgy,

Thanks for the update.

The SfRichTextBoxAdv supports (multi selection) selecting different portions of the document at a time. Using this option, you can select all the occurrence of replaced text.

Also, created a sample to demonstrate the same which can be downloaded from the below location.
https://www.syncfusion.com/downloads/support/forum/171123/ze/SFRICH~1-952591641

Please refer to the below link to know more about multi selection in SfRichTextBoxAdv control
https://help.syncfusion.com/wpf/richtextbox/selection#multi-selection 

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan
 
 



GG Gyorgy Gorog December 16, 2021 07:03 PM UTC

Kalaivannan , you are cheating :)

I need this:

for (int i = 0; i < textSearchResults.Count; i++)
{
   TextSearchResult textSearchResult = textSearchResults[i];
// show this single searchresult to user
RichTextBoxAdv.Selection.Select(textSearchResult.Start, textSearchResult.End);
Thread.Sleep(1000);
   textSearchResult.Replace(replaceText.Text);
// show how nicely we replaced it
Thread.Sleep(1000);

I wonder if this works for you :)
Thanks.


KG Kalaivannan Ganesan Syncfusion Team December 17, 2021 06:50 PM UTC

Hi Gorog,

Thanks for the update.

Understanding your previous requirement:
We suspected that, as you wanted to replace and select all the occurrences of the replaced text. But after the replacement completion, the last occurrence alone was selected. Thus, to achieve your requirement we have created a workaround using build-in APIs and shared the custom sample.

Replace and Replace-All Behaviour:
As we follow MS word standards, when Replace operation is performed it will replace and select the replaced single word.

When Replace-All operation is performed, the entire occurrence of the text will be replaced but none of the the replaced text would be selected. You can confirm these behaviors in the MS word application

Current requirement:
From your last reply, we suspect that you wanted to replace the text one by one, and as soon as the text is replaced, it should be selected. We are working on your requirements and update you with the custom sample within two working days on or before 21st December 2021.

And please confirm for us, is it a requirement from your side? if the suspected requirement is wrong, please provide us with the requirement clearly because it will help us to provide you with the appropriate solution at the earliest

Please let us know if you have any other questions,

Regards,
Kalaivannan Ganesan
 



GG Gyorgy Gorog December 18, 2021 07:49 AM UTC

Kalaivannan,

replace the text one by one, and as soon as the text is replaced, it should be selected.

the text portions to be replaced are all different, you cannot replaceAll them.

they are in a TextSearchResults collection.

yes, this is my goal. 

Thank you.



KG Kalaivannan Ganesan Syncfusion Team December 20, 2021 12:03 PM UTC

Hi Gorog,

Thanks for the update.

Now we are working to achieve your requirement by creating a custom sample. As we promised, we will update you with further details on 21st December 2021.

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan
 



KG Kalaivannan Ganesan Syncfusion Team December 21, 2021 12:53 PM UTC

Hi Gyorgy,

Thanks for your patience.

The SfRichTextBoxAdv does not have direct support for performing asynchronous find and replace operations. But as a workaround, you can achieve the requirement using
DispatcherTimer, where the text is replaced with a specified interval of time.

Also, we have created a sample(.NET 6.0) to demonstrate the same which can be downloaded from the below location.

Sample Link:
https://www.syncfusion.com/downloads/support/forum/171123/ze/RTE_NetCore2014211805

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan
 


Marked as answer

GG Gyorgy Gorog replied to Kalaivannan Ganesan December 21, 2021 04:42 PM UTC

Thanks,  Kalaivannan, it is just perfect as it comes.


Loader.
Up arrow icon