Current View Display Lines

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Hassan
Version: 3.1.0225
Avatar
Hi !

I am trying to retrieve the text of the lines that are displayed in the selected view. For example, if the currently selected view is displaying the lines 3 To 41, then I want to retrieve the text of these lines. I tried a few methods in SyntaxEditor.SelectedView, but I can't find the function that can do it.

Kindly show me the way to do it.

Regards,
Hassan

Comments (2)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Hassan,

Something like this is probably what you want:
TextRange range = new TextRange(
    editor.SelectedView.DisplayLines[editor.SelectedView.FirstVisibleDisplayLineIndex].StartOffset
    editor.SelectedView.DisplayLines[editor.SelectedView.FirstVisibleDisplayLineIndex + Math.Max(0, editor.SelectedView.VisibleDisplayLineCount - 1)].EndOffset
    );
string text = editor.Document.GetSubstring(range);


Actipro Software Support

Posted 13 years ago by Hassan
Avatar
Thanks a lot Sir. Worked great (:
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.