Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Vertical Scroll Bars Rich Text Box

How do I get a vertical scroll bar to scroll down with the text entered into Rich Text Box Control?  I have given the rich text box the following properties:

this.displayTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.displayTextBox.Multiline = true;

But the scroll bar stays at the top of the rich text box when the text is greater than the length of the text box!!  Can anyone provide any code so that the scroll bar stays at the bottom of the rich text box?
0
garth15
Asked:
garth15
2 Solutions
 
AlexFMCommented:
I made small test and found that when user types text to multi-line RichTextBox, it is scrolled down automatically.
However, when text is set from the program, this doesn't happen. To do this you can use ScrollToCaret function:

richTextBox1.Text = "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2";       // test
richTextBox1.Select(richTextBox1.Text.Length, 0);
richTextBox1.ScrollToCaret();
0
 
SRigneyCommented:
RichTextBox1.SelectionStart = RichTextBox1.Text.Length;
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now