ExtensionMethod.NET Home of 818 C#, Visual Basic, F# and Javascript extension methods

ScrollToBottom

Scrolls to the bottom of a Textbox.

Source

public static class ExtensionMethods
{
	/**
	 * <summary>Scrolls to the bottom of a TextBox.</summary>
	 *
	 * <remarks>The scroll occurs by moving the caret and scrolling to it;
	 * therefore you shouldn't use this method if caret placement is
	 * important in your application.</remarks>
	 */
	public static void ScrollToBottom(this System.Windows.Forms.TextBox box)
	{
		box.SelectionStart = box.TextLength;
		box.ScrollToCaret();
	}
}

Example

this.txtExample.ScrollToBottom();

Author: Sean Fox

Submitted on: 25 dec 2008

Language: C#

Type: System.Windows.Forms.TextBox

Views: 2841