Scroll event not firing

SyntaxEditor for Windows Forms Forum

Posted 4 years ago by Marc Beeson - Precision Mining
Version: 20.1.0400

The SyntaxEditor.Scroll event doesn't seem to fire in the new version. I have 2 syntax editors that need to have their vertical scroll positions syncronised. Is read in the WPF forum to use the Layout event, but I feel there should be a better way.

[Modified 4 years ago]

Comments (2)

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Marc,

I don't believe SyntaxEditor ever raised the inherited Scroll event.  In the newer codebase, if you have two SyntaxEditors to keep in sync, you'd first want to disable view splitting by setting SyntaxEditor.CanSplitHorizontally to false.  Then attach to the SyntaxEditor.ActiveView.TextAreaLayout event.  That will fire whenever changes to the view occur, such as changes that can affect scrolling.  The view's ScrollState property gives the current scroll state.  If you wish to sync up the other editor, you can use the SyntaxEditor.ActiveView.Scroller.ScrollTo() method.

Actipro Software Support

Posted 4 years ago by Marc Beeson - Precision Mining

This TextAreaLayout event approach works well enough for our purposes. To allow independant horizontal scrolling I used the following code:

var otherView = e.View == editorOld.ActiveView ? editorNew.ActiveView : editorOld.ActiveView;
var scrollState = new TextViewScrollState(new TextPosition(e.View.ScrollState.VerticalAnchorTextPosition.Line, 0), e.View.ScrollState.VerticalAnchorPlacement, e.View.ScrollState.VerticalAmountOffset, otherView.ScrollState.HorizontalAmount);
scrollState.CanScrollPastDocumentEnd = true;
The latest build of this product (v24.1.0) was released 5 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.