3

I am using the Scintilla .NET text editor control (ScintillaNet.dll) to display SQL. I am using the following command to position the caret cursor at a given line number. In the example below, I am positioning the caret cursor at line 102 (0 based. The grid displays 1-based line numbers.)

scintilla1.GoTo.Line(102); //0 based

What I get

I'd like text in the viewport to be displayed at the top of the screen as shown below, as the first visible line

What I want

How can I identify how to do this?

Update

This looked promising:

scintilla1.Lines.FirstVisible.Number = targetLineNumber;

but after executing, scintilla1.Lines.FirstVisible.Number wasn't always equal to targetLineNumber and I don't know what is interfering with it.There are hundreds of lines following the targetLineNumber line.

halfer
  • 19,824
  • 17
  • 99
  • 186
Chad
  • 23,658
  • 51
  • 191
  • 321
  • Take a look at this answer. Hopefully, that will help you. https://stackoverflow.com/questions/10675217/how-to-move-the-cursor-to-a-specific-position-in-a-specific-line-in-scintillanet – Michaela Joy Apr 20 '18 at 22:49

1 Answers1

1

Get/Set first visible line works for me https://www.scintilla.org/ScintillaDoc.html#SCI_SETFIRSTVISIBLELINE

You can keep the cursor position first (SCI_GOTOPOS) and then set the first visible line

liqian
  • 134
  • 1
  • 6