Autoscroll in C# RichTextBox

using System.Runtime.InteropServices;
#region WinAPI
//WinAPI-Declaration for SendMessage
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(
IntPtr window, int message, int wparam, int lparam);
const int WM_VSCROLL = 0x115;
const int SB_BOTTOM = 7;
#endregion
SendMessage(richTextBox1.Handle, WM_VSCROLL, SB_BOTTOM, 0);

Comments

  1. That is a much better solution than the ScrollToCaret() method that many people use.

    I have wrapped it in a class for people that are unfamiliar with the whole WinAPI thing.

    ReplyDelete

Post a Comment

Popular posts from this blog

Parse XML to dynamic object in C#

C# Crop white space from around the image