11,567 questions
You can use SetScrollPos to set the scrollbar position, and then use PostMessage to adjust the text to the corresponding position.
public Form1()
{
InitializeComponent();
}
private const int SB_VERT = 0x1;
[DllImport("user32.dll")]
public static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);
[DllImport("User32.Dll", EntryPoint = "PostMessageA")]
static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
private void button1_Click(object sender, EventArgs e)
{
SetScrollPos(richTextBox1.Handle, SB_VERT, 100, true);
PostMessage((IntPtr)richTextBox1.Handle, 0x115, 4 + 0x10000 * 100, 0);
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.