Programatically set selection

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Paul Huckstepp - UK
Avatar
I've looked everywhere on the forum and the user guide but I cannot work out how to set the selection from code. I have calculated the first charater position and the last character position but I cannot work out how to select the text between these two characters.

Can anyone help?

Comments (5)

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Look at the SyntaxEditor.SelectedView.Selection.StartOffset or .StartPosition properties to say where selection starts, and then .EndOffset or .EndPosition to say where selection ends.
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Anything to do with selections should always be done with the editor.SelectedView.Selection object. It has a ton of methods for doing just about anything. There is also a SelectRange method on it that lets you give the start offset and length of the selection to change to.


Actipro Software Support

Posted 19 years ago by Paul Huckstepp - UK
Avatar
Thanks for the speedy response.

I've managed to sort out the selection commands but they seem to start at the begining of the document rather than the current line. Is it possible to set the selection starting from the current line, i.e. column 1 is character 1?

Thanks again.
Posted 19 years ago by Paul Huckstepp - UK
Avatar
I've reworked my code and managed to sort out the selection code.
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes each offset is based on the beginning of the document however you can easily find the start offset of each line by using DocumentLine.StartOffset.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.