RichTextBox否平滑滚动C# [英] RichTextBox no Smooth scrolling C#

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

问题描述

你好,
我有一个RichTextBox.但是,当您滚动时(使用RTB的滚动条和鼠标上的滚轮),它平滑地"滚动(以像素为单位),但是我希望它逐行滚动.这可能吗?

问候,
Tim

Hello,
I have a RichTextBox. But when you scroll (using scrollbar of the RTB and scrolling wheel on mouse) it scrolls ''smoothly''(in pixels), but I want it to scroll line by line. Is this possible?

Greets,
Tim

推荐答案

问题是:在富文本中,没有这样的想法,即在整个文本中存在恒定的行间间隔.即使从理论上讲可以精确滚动N行(在最后一行中选择一个范围,然后按下N次),但此操作的执行速度可能会非常慢. (并且无论如何不要以这个示例作为实现的思想:输入模拟是一个肮脏的把戏,绝对不能在不错的UI开发中使用.)

与其他导航操作相比,滚动非常快,这仅是因为滚动是几何"而不是逻辑"的,所以这是可能的.您不应将此重要功能替换为任何其他可疑的功能".

即使您可以使用某种附加控件引入替代滚动",也不要指望用户会喜欢它.我最好的建议是:保持原样;保持平稳. :-)

如果确实需要逐行移动,则可能不需要富文本格式,并且确实需要列表框,列表视图或网格控件…

—SA
The problem is: in rich text, there is no such think as constant inter-line interval throughout the text. Even though scrolling by exactly N lines is theoretically possible (select a range in a last line and press Down N times), the performance of this operation could be prohibitively slow. (And don''t take this example as the idea for implementation anyway: input simulation is a dirty trick, should never be used in decent UI development.)

Scrolling is very fast compared to any other navigation operation, and this is only possible because the scrolling is "geometrical", not "logical". You should not replace this important functionality with any other questionable "feature".

Even if you could introduce "alternative scrolling" using some additional control of some kind, don''t expect the user appreciate it. My best advice is: leave it as is; keep it smooth. :-)

If you really need to move line by line, maybe the rich text is not what you need, and you really need a list box, a list view or a grid control…

—SA


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

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