Solved

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

Posted on 2004-08-19
2
909 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now