滚动到RichTextBox中的位置 [英] Scroll to Position in RichTextBox

查看:123
本文介绍了滚动到RichTextBox中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在滚动到富文本框中突出显示的文本/字符串位置时,我需要帮助.我能够找到文本并将其突出显示,但是我希望用户能够单击下一步"按钮,并且该事件可滚动到第一次出现突出显示的单词时的垂直偏移位置,然后滚动到下一个,依此类推.任何专门用于查找突出显示的文本的行的垂直偏移的位置的帮助也将有所帮助.预先感谢.

I need help in scrolling to highlighted text/string positions in a rich text box. I was able to find text and highlight it but I want the user to be able to click on a Next button and that event to scroll to the vertical offset position of the first occurrence of the highlighted word to the next and so on after each click. Any help specifically with finding the position for the vertical offset of the line of the highlighted text would be helpful as well. Thanks in advance.

推荐答案

我找到了类似问题的答案

I found an answer to a similar question here. Below is the code that I believe will do the trick for you.

TextPointer start = txtEditor.Selection.Start;
FrameworkContentElement fce = (start.Parent as FrameworkContentElement);
if (fce != null)
{
    fce.BringIntoView();
}

这篇关于滚动到RichTextBox中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆