I am trying to scroll a stored line index into view in the syntax editor I have after a modification.
The user has the ability to view code in the syntax editor, change a property from a property grid, which edits code and gets loaded into the syntax editor.
I reload the modified code into the syntax editor after the code string is modified. Before I reload the code into the editor, I store the line index of the current displayed line. Then I set the Text property of the syntax editor. Once the code is loaded, I set the first visible line index to the index I saved previously, then I call the ScrollLineToVisibleTop() method.
The code in the syntax editor is not scrolled to the line index I set. It keeps jumping to the first line of code in the syntax editor. Is there some way I can perform this? Am I on the right track, or am I simply missing something? Any help would be appreciated. (Sample code follows)
The user has the ability to view code in the syntax editor, change a property from a property grid, which edits code and gets loaded into the syntax editor.
I reload the modified code into the syntax editor after the code string is modified. Before I reload the code into the editor, I store the line index of the current displayed line. Then I set the Text property of the syntax editor. Once the code is loaded, I set the first visible line index to the index I saved previously, then I call the ScrollLineToVisibleTop() method.
The code in the syntax editor is not scrolled to the line index I set. It keeps jumping to the first line of code in the syntax editor. Is there some way I can perform this? Am I on the right track, or am I simply missing something? Any help would be appreciated. (Sample code follows)
// Save our line index so we can keep the modified code in view
int nStartPos = editor.SelectedView.FirstVisibleDisplayLineIndex;
editor.Text = this.CS_Code; // Load the modified code into the editor
editor.SelectedView.FirstVisibleDisplayLineIndex = nStartPos;
editor.SelectedView.ScrollLineToVisibleTop();