473,461 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

(Rich)TextBox, scrolling, HideSelection

Hi-
In my application I have a RichTextBox, and I want to scroll it so that
the character at a given index appears on the top line of the box. Up
till now, I've used this routine, which works fine:

==
rtb.Focus();
rtb.SelectionStart=rtb.Text.Length-1;
rtb.SelectionLength=0;
rtb.SelectionStart=rtb.Text.IndexOf("MY_TEXT");
rtb.SelectionLength=0;
==

However, recently I've been adding a search feature, and as a result
I've needed to set the RTB's HideSelection property to false. An
unfortunate side-effect of this is that for some reason the above code
no longer works. I've experimented with ScrollToCaret combinations, but
the problem is that if MY_TEXT is visible on-screen but half-way down
the textbox, then calling ScrollToCaret will never move the box.

Does anyone have a solution?

Cheers,
Andy

Nov 17 '05 #1
1 5620
<a_**********@hotmail.co.uk> wrote:
In my application I have a RichTextBox, and I want to scroll it so that
the character at a given index appears on the top line of the box. Up
till now, I've used this routine, which works fine:

[...]

However, recently I've been adding a search feature, and as a result
I've needed to set the RTB's HideSelection property to false. An
unfortunate side-effect of this is that for some reason the above code
no longer works.

I've experimented with ScrollToCaret combinations, but
the problem is that if MY_TEXT is visible on-screen but half-way down
the textbox, then calling ScrollToCaret will never move the box.


I'm unable to reproduce your problem (whether HideSelection is true or
false). Here's the relevant code from my test project:

rtb.Focus();
rtb.SelectionStart=rtb.Text.Length-1;
rtb.SelectionLength=0;
rtb.SelectionStart=rtb.Text.IndexOf("MY_TEXT");
rtb.SelectionLength=0;
rtb.ScrollToCaret();

The RichTextBox is pre-filled with some 100 lines of text, with "MY_TEXT"
occuring once halfway through. When I run the above code, the RichTextBox
scrolls so that the line containing "MY_TEXT" is the top visible line.

Are you sure you're calling RichTextBox.Focus in your real code? This
could cause your problem (but only if HideSelection is true).

If you still can't solve this, create a new project and add the relevant
code to the form's file, and post that file here (either attach it to your
post or upload it to some file server and provide a link to it).
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bala | last post by:
hi there the senario - an A2k application is distributed as a mdb to various users. they are not packaged. rich textbox is being used in one form. requirement - in some of the user's machine...
2
by: Neil | last post by:
Is there an editable RTF textbox control which allows the user to apply bold, italic, etc.? I tried the Microsoft Rich Textbox Control, but there doesn't seem to be a way to allow the user to...
3
by: hermawih | last post by:
Hi , can anyone help me , please . In Ms Rich textbox control , It is easy to insert object than to insert picture . I want to insert picture in my Ms rtf activeX control but Ms Access does...
4
by: Brett | last post by:
I have a rich textbox on a form. Sometimes after running the application in debugging mode, the rich textbox will disappear. Sometimes when I switch to design mode, it will also disappear (after...
1
by: tomi.trescak | last post by:
Hi I have a problem with storing rich text in MySQL. I store rich text in MySQL (in column with type "text") which i get from Rich Textbox control. When i do reverse processing by trying to...
3
by: natrajsr | last post by:
Hi, I want to load the data of a excel sheet or in the exact excel sheet format into a Rich TextBox control. I have already worked with loading WORD into a Rich TextBox. It is working fine.;...
10
by: Neil | last post by:
Using the MS Rich Textbox Control 6.0 in Access 2000, I need to concatenate several RTB controls into a single RTF file. Sometimes two strings will be side-by-side; other times they need to be...
6
by: Neil | last post by:
I'm having problems with an implementation of the Microsoft Rich Textbox Control 6.0 in an Access 2000 database. The form with the controls works fine except on two computers. On these computers,...
0
by: Neil | last post by:
I am having trouble using long dashes (Em dashes) with the Microsoft Rich Textbox 6.0 control. Whenever I paste them in, the control converts them to hyphens. I have found it is the same with the...
5
by: BarryM | last post by:
could somebody please tell me how to search a rich textbox for a particular word and then highlight that word in the rich textbox ; ; on the form theres are textbox called txtsearch, a button...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.