link

well the other day, I was writing a custom windows IM implementation, and I wanted to append the chat text to the bottom of the textbox, when I noticed that the standard RichTextBox didnt have a ScrollToEnd() function, so I added my own.
just incase you havent already figured out how to do it (pretty simple) and need it too, here's mine:
<em>/*
* Copyright © 2004 NullFX Software
* By: Steve Whitley
*
* $Log: RichTextBox.cs,v $
*
* */
namespace NullFX.Windows.Forms {
using System;
//using System.Drawing;
using System.Windows.Forms;
/// <summary>
/// This components adds a much lacking function
/// "Scroll to the end" which is missing
/// from the original rich text box.
/// </summary>
//[ToolboxBitmap("RichTextBox.bmp")]
public class RichTextBox : System.Windows.Forms.RichTextBox {
/// <summary>
/// Scrolls the text to the bottom of the rich text box.
/// </summary>
public void ScrollToEnd() {
// place our cursor at the end of the text
base.SelectionStart = base.Text.Length;
// create a new message to scroll to the
// bottom of the textbox
Message m = Message.Create(base.Handle, 277/*WM_VSCROLL*/, (IntPtr)7/*SB_BOTTOM*/, IntPtr.Zero);
// send the message to scroll to the bottom of the textbox.
base.WndProc(ref m);
}
}
}</em>
(I'm too lazy to delete the © header, It aint rocket science)