I need to scroll the content of the RichText control I placed in a
Windows Form by code (C#). Do I need to call native API or can I do so
purely in C#?
Thanks for any hints,
JB.
There is not a C# method to scroll the RichTextBox directly. However, you
may workaround it with the following two ways:
1. Call ScrollToCaret method
Set the create position first, and then call the ScrollToCaret method to
scroll to the position. For example:
richTextBox1.Select(richTextBox1.TextLength,0);
richTextBox1.Focus(); //the richtextbox will not scroll if it is
notfocused.
richTextBox1.ScrollToCaret();
2. Send/post WM_VSCROLL message
Call the SendMessage/PostMessage API via PInvoke, and send the proper
WM_VSCROLL message to scroll the RichTextBox
I hope this helps you.
Best regards,
Lion Shi [MS]
MCSE, MCSD
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: "JBLi" <news gr...@jbli2000.com>
Subject: How can I scroll a RichText content via code? Please help.
Date: Wed, 13 Nov 2002 15:22:45 -0500
Lines: 11
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <ef5P0I1iCHA.2736@tkmsftngp10>
Newsgroups: microsoft.public.dotnet.framework.windowsforms.controls
NNTP-Posting-Host: 141.149.61.239
Path: cpmsftngxa06!tkmsftngp01!tkmsftngp10
Xref: cpmsftngxa06
microsoft.public.dotnet.framework.windowsforms.controls:3750
X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms.controls