I did some further experimentation with ScrollToCaret and it just does not end up in the same position every time. Since my goal is limited to only scrolling all the way to the bottom, it was then a good candidate for sending the WM_VSCROLL message (277, or 0x115) to the control, with wParam of SB_PAGEBOTTOM (7). This consistently scrolls all the way to the very bottom exactly like I needed:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
private const int WM_VSCROLL = 277;
private const int SB_PAGEBOTTOM = 7;
public static void ScrollToBottom(RichTextBox MyRichTextBox)
{
SendMessage(MyRichTextBox.Handle, WM_VSCROLL, (IntPtr)SB_PAGEBOTTOM, IntPtr.Zero);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…