Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Sergey Alexandrovich Kryukov 27-Jan-12 14:47pm    
Why?! What if your users want to scroll as it is now?
--SA
Sergey Alexandrovich Kryukov 27-Jan-12 14:50pm    
What RichTextBox? Do you think there is only one type under this name? No!
You need to give us a fully-qualified name. Also, tag your UI library: WPF, Forms, something else.

However, in this very case I don't think this is relevant.
But! Some other expert might think this is important -- tag it!
--SA
LanFanNinja 28-Jan-12 0:05am    
I totally agree with what SAKryukov is saying here. I have used applications with text areas that only scroll line by line and for some reason it really bothers the crap out of me.

This is however your application and if you feel you need/want this functionality then by all means go on and implement it. :)
ikkentim 28-Jan-12 5:18am    
Do you still have the script for it? At least I wat to try in :)

1 solution

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
 
Share this answer
 
Comments
Sean A. Hanley 27-Jan-12 18:18pm    
Assuming he means WPF, I know with some scrollable containers you can influence the smooth-scroll/line-by-line-scroll behavior by manipulating ScrollViewer.CanContentScroll but this only works when the list contents is virtualized and has some kind of discrete list of things to scroll (i.e. other WPF controls)... with text, well... I think SAKryukov is right, there ain't a good way, really.
Sergey Alexandrovich Kryukov 27-Jan-12 18:27pm    
This is reasonable. Thank you for this comment, Sean.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900