Support Scroll to Bottom
(NB Thanks VisualG at CodeProject, see http://www.codeproject.com/Articles/335909/Embedding-a-Console-in-a-C-Application?msg=4642047#xx4642047xx)
This responce is a little late i know, but there are probably more people that want to know how to do this.
if u want the richtextbox to auto scroll down when text is appended u can use this code
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam);
private const int SbBottom = 0x7;
private const int WmVscroll = 0x115;
//call this in a method after appending text in the richtextbox
//dont forget to change richtextbox1 with youre richtextboxcontrol
SendMessage(richtextbox1.Handle, WmVscroll, SbBottom, 0x0);
In WPF, all you need to do is add
richTextBoxConsole.ScrollToEnd();
into ConsoleControl.xaml.cs after appending the text inside WriteOutput().
I guess this is dead, however for the future reference of anybody thinking to use this component with the fix suggested here I can warn you: it is hideously slow. It takes about 2 minutes to add 5000 lines to console if you also perform ScrollToEnd after each one.
I know this is probably even more dead than when the last poster commented but I discovered a simple way to auto scroll even in Windows Forms. Within the onConsoleOutput event on the control, just add the lines:
ConsoleControl.ConsoleControl console = sender as ConsoleControl.ConsoleControl; console.InternalRichTextBox.ScrollToCaret();
This worked fine for me and didn't seem to have much of an effect on performance. However if the lines are coming very thick and fast you could do the scroll every so many event triggers rather than each one.
Thanks for the tip @ashleyemery, hopefully this'll help anyone who has the same problem. I'm unlikely to have the time to add this, but am open to PRs!
I know its too late. But if someone finds it helfull add this inside your form [DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam);
call this via SendMessage(consoleControl1.InternalRichTextBox.Handle, WmVscroll, SbBottom, 0x0); where consoleControl1 is the name of your consoleControl