Solved

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

Posted on 2004-08-19
2
912 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:Khopkins32
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
bigjim2000 earned 250 total points
ID: 11849878
OK, here's how you can do it:

In your method do (assuming rtb is your rich text box):

rtb.Focus();
rtb.Text = variable;
rtb.Select( variable.Length, 0 );
rtb.ScrollToCaret();

This will scroll your box to the bottom.

-Eric
0
 
LVL 3

Expert Comment

by:bigjim2000
ID: 11856761
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
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question