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.
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
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.
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.
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.
Thanks, Kalaivannan, it is just perfect as it comes.