PavelTorgashov / FastColoredTextBox

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

How to restore position of cursor #115

Closed KaustubhPatange closed 6 years ago

KaustubhPatange commented 6 years ago

I am trying to make an advance notepad type application, I've tried to make it best as possible. Only thing i want to implement is how to restore the cursor position when the applications close and restore it back when the application loads.... Any idea..

What I thought ? To save the line number upon exit, to an xml. Retrieve upon startup.. And set it to fctb. Here is my code

void GotoLine(int wantedLine_zero_based) // int wantedLine_zero_based = wanted line number; 1st line = 0
{
    int index = fctb.GetFirstCharIndexFromLine(wantedLine_zero_based);
    fctb.Select(index, 0);
}

But it says GetFirstChar** is not in context.. Any solution or If you have a better solution for this. Please let me know

Thanks in Advance !

PavelTorgashov commented 6 years ago

The FCTB does not contain method GetFirstCharIndexFromLine. If you want to select some line and scroll to it, use following code:

fctb.Selection.Start = new Place(0, iLine);//select first char of line iLine
fctb.DoSelectionVisible();//scroll to selection