[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I stop the cursor jumping on space or punctuation when highlighting text in a RichTextBox?

Posted on 2007-12-04
11
Medium Priority
?
307 Views
Last Modified: 2013-12-16
I am writing a text re-formatting program based on the character type (e.g. number, letter etc) of the exact characters selected. It needs fine control of the highlight text. Using a RichTextbox the highlight jumps to the next word given spaces or punctuation. I need it to hightlight (and select) only the columns that I have selected with the cursor and stop being 'helpful'.
I note the behaviour appears correct (for me) in TextBox.
0
Comment
Question by:markbeasley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20402908
>>I need it to hightlight (and select) only the columns

I don't understand what you mean by "columns"?  

>>Using a RichTextbox the highlight jumps to the next word given spaces or punctuation

What do you mean by this?

Bob
0
 

Author Comment

by:markbeasley
ID: 20409690
Sorry that it was not clear.
We are re-formatting data files and filtering data on the basis of a particular character type such as number, space, letter etc being in a certain column position in the data file. For example, I might want to hghlight the following string
CMNT,
Out of the complete line:
CMNT,,,PROJECT...1234
As soon as the cursor gets to the "." in column position 5 the highlight jumps to column postion 7 i.e. the begining og the next word "PROJECT"
Hope this helps!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20411447
>>As soon as the cursor gets to the "." in column position 5 the highlight jumps
Can you give me some coding insight into your processing steps, because the words aren't cutting it?

Bob
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:markbeasley
ID: 20412830
Hi Bob,
The difficulty is that it is the default behaviour of the RichTextBox. Put it another way, if you copy this data snippet into WordPad and try highlighting "CMNT." on he first line you will find the highlight will jump to the next word.
If you use NotePad then you are able to highlight the exact substring. It is the NotePad behaviour I am after, Note that TextBox behaves like NotePad, RichTextBox behaves like Wordpad.
Thankyou for your patience!

CMNT...PROJECT...XXX16
CMNT...AREA......AREA 3D
CMNT...SURVEY....3D 1994 (RE-MIGRATION)
CMNT...PROCESSED.SPECIAL IN-HOUSE PROCESSING GROUP
CMNT...          (GLASGOW)
CMNT...
CMNT...FORMAT(1) SPNT CARD
CMNT     >3DCDP> > 3D SP <>X-COORD<> Y-COORD <    >LINE<
CMNT...
CMNT...FORMAT(2) VELF CARD
CMNT     >3DCDP>    > T1 X V1 X T2 X V2 X T3 X V3 X T4 X V4 X T5 X V5 <
CMNT...
CMNT...THE PROCESSING GRID
CMNT     X1: 380642.40   Y1: 5851119.10   LINE:    1   SHOTPOINT:    1
CMNT     X2: 393796.67   Y2: 5867027.63   LINE:    1   SHOTPOINT: 1549
CMNT     X3: 362057.79   Y3: 5866486.13   LINE:  690   SHOTPOINT:    1
CMNT     PRIMARY PROFILE CELL SIZE.......13.335 M
CMNT     SECONDARY PROFILE CELL SIZE.....35.0 m

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20412924
Hmmm, I have:

Windows XP Professional SP2
Visual Studio 2005 Professional SP1

I tried to double click CMNT on the first line, and it worked.  I tried to highlight CMNT on the first line, and it worked.

Bob
0
 

Author Comment

by:markbeasley
ID: 20419058
Hi Bob,
No double clicking. Lets say you want to copy the string "CMNT. "- try and do this is Wordpad and as soon as the cursor reachs the ". "selection will jump to just before the "P"
Another example,
Open Wordpad and type My name is Bob
try copying the substring "My n" - again you will find the selection will try and be helpful and the word "name" will get selected as well.
To re-cap, when dealing with data this behaviour is undesirable and I want to switch it off in Richtextbox.

Mark

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20419561
I didn't mean that I was only double-clicking, I meant that I tried everything that I could think of to highlight CMNT (including double-clicking), and it worked as expected.  I even opened WordPad, and tried the same processes, and it also worked as expected.

There aren't any properties to control this behavior with the RichTextBox, so you need to look elsewhere for a possible solution.

Bob
0
 

Author Comment

by:markbeasley
ID: 20420127
The property that controls the behaiour is AutoWordSelection

There is a known bug that setting this to false has no affect. MicroSoft has it marked as "closed wont fix" for details see:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115441
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20420308
Ok, so I missed that property (d'oh) :(

Changing that property value doesn't affect how the text is selected with my RichTextBox, I can still select CMNT without it extending the selection to include the '...'.

Bob
0
 

Author Comment

by:markbeasley
ID: 20420445
The key is selecting CMNT.    - The "." is vital, this triggers the AutoWordSelection

See http://www.msdner.com/dev-archive/128/2-8-1286449.shtm
for a solution to the problem.

Thanks for your help

Mark
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 20420531
Mark,

That is an interesting solution, but it is also interesting that I don't need anything like that for my simple RichTextBox to work.

Bob
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question