问题
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