How to use VScrollBar and HScrollBar together with a RichTextBox?

你说的曾经没有我的故事 提交于 2020-01-06 05:31:05

问题


In my form I have a RichTextBox. I also have a VScrollBar and HScrollBar. I set the RichTextBox property ScrollBars to None so I can use the new scroll bars for it. Thats where I hit a problem, how do I do it? I searched online and found nothing for "c# richtextbox vscrollbar"

Please add references to articles to your answers so I can learn how it works.


回答1:


I don't know if there is a way to do what you want. The best thing I can thing of would be to try and find the right position in the text, then Select() and ScrollToCaret(). I usually only use that trick to force a TextBox/RichTextBox to scroll to the very end, though. It wouldn't be very easy to use it for what you want.

Is there a reason why you don't want to use the default scroll bars?

In my experience, I've rarely had any luck anytime I've tried to use custom scroll bars in C# - especially with a control that has the ability to auto-scroll built it.

The only time I've used them without too much trouble is with a third party control that didn't have an auto-scroll capability.



来源:https://stackoverflow.com/questions/946840/how-to-use-vscrollbar-and-hscrollbar-together-with-a-richtextbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!