how best to detect when the caret changes lines?

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Blaise
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!


Comments (2)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
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 19 years ago by Blaise

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 (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.