Link to home
Start Free TrialLog in
Avatar of Khopkins32
Khopkins32

asked on

Using a Rich Text Box to Display Output Stream for a running process in Execution

Dear Expert,
    I have a Rich Text Box winform control used to display output stream information of  a process in execution. When the text being displayed populates the full height(area) of the rich text box,, it doesn't automatically scroll down. The only way to mimick this behavior is if I click my mouse in the Rich Text Box, just after the end of line of the process text string (i.e placing the cursor in a carriage return line feed position). Is there a way to set the Rich Text Box to automatically stay in scroll down position as output text populates the area of the rich text box.

I current set a string variable equal to the output stream. Then I set "this.text = string variable" to display the output stream.

Regards

-K
ASKER CERTIFIED SOLUTION
Avatar of bigjim2000
bigjim2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bigjim2000
bigjim2000

I suppose another handy thing to do would be to just create this private method:

private void ScrollToBottom(System.Windows.Forms.RichTextBox rtb)
{
  rtb.Focus();
  rtb.Select( rtb.Text.Length, 0 );
  rtb.ScrollToCaret();
}

Then you just call this method, and pass the RichTextBox you want to scroll to the bottom.... Handy :-)

-Eric