How to move to a certain position

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by GeorgeNY - CTO, RatchetSoft, LLC
Avatar
How do i move the caret to line 6 column 27?

George P Weihs

Comments (3)

Posted 14 years ago by Boyd - Automated Software Testing Consultant / Developer, Patterson Consulting, LLC
Avatar
Take a look at the 'SyntaxEditor.SelectedView.Selection' class. It provides many properties and method for adjusting position. Typically, you want to use Offsets in SyntaxEditor (which is an index starting from the beginning of the document). I believe the Document Lines collection (can't recall where it's located) will allow you to find a particular line and get the starting offset of that line. YOu would then add 26 to the starting offset to get the offset for column 27.

It was initially difficult for me to adjust to using offset, but it's proven to be a very good implementation.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You can also use the SyntaxEditor.Caret object's properties. Position structures let you work with character and lines. So you can convert a Position to an offset using Document.PositionToOffset. There is a matching OffsetToPosition method that goes the opposite way.


Actipro Software Support

Posted 14 years ago by GeorgeNY - CTO, RatchetSoft, LLC
Avatar
Thank you both, that works nicely

George P Weihs

The latest build of this product (v2018.1 build 0341) 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.