windows runtime - UWP/WinRT: How to scroll a RichEditBox to the cursor position? -


i've implemented find function on richeditbox when executed search query , select found text inside richeditbox:

string^ doctext; currentricheditbox->document->gettext(text::textgetoptions::none, &doctext); start = currentricheditbox->document->selection->endposition; end = doctext->length(); int result = newrange->findtext(query, end-start, text::findoptions::none); if (result != 0) {     currentricheditbox->document->selection->setrange(newrange->startposition, newrange->endposition); } 

this works, in text found selected. however, richeditbox contents long scroll, off-screen , richeditbox won't scroll bring view. oddly enough, however, if code re-run it'll scroll view previous result. example, take following text:

this test

[screen end]

1 hat

2 hat

when code searches hat, highlight first instance of word hat. however, richeditbox won't scroll down it, though it's off-screen. second time code run, both highlight second instance , scroll screen down first instance of word hat.

i assuming there bug in code richeditbox causing this. there programmatic way can manually scroll richeditbox or implicit scrollviewer bring caret view?

to scroll highlighted text position, you'll need use scrollintoview method available on itextrange interface.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -