how best to detect when the caret changes lines?

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Blaise
Avatar
OK, this nube wants to be able to take an action when the caret is moved from one line of text (code) to another in the SyntaxEditor. What is the best way to do this?

The brute force way works (handle the key-up event for certain keystrokes [up, down, left, page-down, etc] and the mouse-up event, and then see if the caret line position is changed) ... But I figure there must be a better way!

Thanks.

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Blaise, use the SelectionChanged event. It fires when the selection (caret) is modified so you can track whether the line changes between instances of it. The editor.Caret.Position.Line tells you what line the caret is on.


Actipro Software Support

Posted 14 years ago by Blaise
Avatar
Excellent!

Actually the SelectionEventArgs object passed to the SelectionChanged event has both the LastPosition and the (current) Position ... exactly what I need. Thanks!


[Modified at 06/14/2005 06:26 AM]
The latest build of this product (v2020.1 build 0400) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.