Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I scroll a RichText content via code? Please help.

21 views
Skip to first unread message

group@jbli2000.com JBLi

unread,
Nov 13, 2002, 3:22:45 PM11/13/02
to
Hi All,

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.


Lion Shi

unread,
Nov 15, 2002, 4:08:37 AM11/15/02
to
Hello,

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

0 new messages