Where is Selection Class?

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by David Wier
Version: 4.0.0233
Avatar
I'm trying to use what I think are the SyntaxEditor replacements for the
SelText - .selectedview.SelectedText
and
SelStart - .Selection.StartEditPosition (or .StartOffset??)

I'm pretty sure the first one (Seltext) is what I'm after, however, using intellisense in VS.Net 2005, '.Selection' doesn't exist - however, the .chm file that comes with 4.xxx says it does..

First - are these what I'm looking for?
and - what am I doing wrong?

Comments (3)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

Yes this will let you get/set the selected text in the current EditorView:
editor.SelectedView.SelectedText
And this is how you get the Selection object which has many methods for manipulating the selection of the selected view:
editor.SelectedView.Selection
If you see an error in the documentation, please let us know so we may correct it. Thanks!


Actipro Software Support

Posted 18 years ago by David Wier
Avatar
Let me explain a little further, in a RichTextbox - the .Selstart property is the place (in the document) either where the cursor is (which is one thing I need to know), and it also is the starting point (in the document) of the selected text.
I'm thinking this might be your StartOffset Property, but I'm not sure, because no where I can find in the documentation are any examples or even a definition of what you are calling an 'offset'. Also, it's only an integer, and I know from experience that some of my users have some long documents, so a 'long' would be a better choice, but, of course, I don't know what I'm looking for. Let me know which property it is, because after an hour of looking through

It's particularly painful, if you are trying to search for specific properties and the language is not straightforward. A case in point, is this, in the Remarks section of the StartOffset Property:
"The start offset may occur after the end offset if the selection is not normalized. The IsNormalized property indicates if the selection is normalized. To get the normalized first offset in the selection, use the FirstOffset property. To get the normalized last offset in the selection, use the LastOffset property. ". Maybe it's just me, but this is a bit circular and does not define anything.

One other thing I'm trying to find is how to programmatically select a particular length. Let's say I have the 'Selstart' (where the cursor is to start the selection. Then, I have a formula which defines the length I'd like to select, from that point.
I tried :
Editor.SelectedView.Selection.Length = Rbracket - lBracket - 10
Of course, it said 'Length' was read only - so how do I achieve something like this, also?

One good suggestion, would be to have samples of how the properties and methods are used, since there are so many.
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

Actually in the "Getting Started" topic there is a big section on all the ways to access text, defining what offsets, positions, etc. all are. Check that out.

For the normalized thing, think of the selection as a range of characters. If the user started creating it at line 5 and then pressed shift+up, the selection is not normalized because the caret is now above the selection anchor. Sometimes you want to know the absolute first offset regardless of whether it is StartOffset or EndOffset. That's what FirstOffset returns. LastOffset returns the absolute last offset. EndOffset is always where the caret appears. And StartOffset is always the "anchor" of the selection.

SelectRange is what you want to use to select a number of characters.

I'll add to the TODO list to add a topic for more info on Selection. Thanks!


Actipro Software Support

The latest build of this product (v24.1.1) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.