Solved

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

Posted on 2004-08-19
2
905 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
Bubble user-defined Sql RAISERROR(...) to c# exception 14 113
asp.net mvc5 3 35
How do I get the id from URL? 19 47
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

16 Experts available now in Live!

Get 1:1 Help Now