SyntaxEditor scrolls to Caret after calling Document.Reparse

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Dave Conkey
Version: 4.0.0284
Platform: .NET 2.0
Environment: Windows Vista (32-bit)
Avatar
Example Code:

public partial class Form1 : Form
{
   public Form1()
   {
      InitializeComponent();

      string text = "";

      for(int i = 0; i < 300; i++)
      {
         text += "sdsdfsfgsg" + Environment.NewLine;
      }

      syntaxEditor1.Document.Text = text;

      syntaxEditor1.Caret.Offset = 1500;

      syntaxEditor1.SelectedView.ScrollToDocumentStart();
   }

   private void button1_Click(object sender, EventArgs e)
   {
      syntaxEditor1.Document.Reparse();
   }
}
After clicking the button, the current view unexpectedly scrolls to the caret location.

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dave,

Whenever selection changes occur, the caret gets scrolled to. The document reparse, triggers a complete UI invalidation, which indirectly raises a selection change that thus kicks off that code.

The only workaround for you would probably be to suspend painting, save the first visible line, do the reparse, restore the first visible line, and resume painting. That may work.


Actipro Software Support

Posted 14 years ago by Dave Conkey
Avatar
I can try that. However, is there any chance of it getting fixed?
Posted 14 years ago by Dave Conkey
Avatar
Nevermind, I found a different workaround.
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.