PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.21k stars 463 forks source link

Get and set first/top visible line #208

Closed LaraSQP closed 4 years ago

LaraSQP commented 4 years ago

I want to retrieve and restore the first/top visible line after an operation.

var place   = fctb.PointToPlace( new Point( 0, 0 ) );
var line    = place.iLine;

fctb.Selection.Start = new Place( 0, line );
fctb.DoSelectionVisible();

I think that code should work but it does not.

I also tried Navigate( line) but this centers the line in the screen.

Thank you in advance. Amazing work.

Storm-23 commented 4 years ago

Best way to restore top visible line - restore vertical scroll position:

var scroll = fctb.VerticalScroll.Value;
...
fctb.VerticalScroll.Value = scroll;
fctb.UpdateScrollbars();
LaraSQP commented 4 years ago

Much appreciated.