How can I get the first visible (top) and last visible (bottom) lines number for Scintilla component in C#? For example, if I scroll the text and I am able to see lines 5-41 (no folding, it is the number of lines which are shown by the component at the moment; the rest, you have to scroll to them), how do I get those numbers programatically?

有帮助吗?

解决方案

If you ever want to find out how to do something with Scintilla, your first stop should always be the core Scintilla Documentation. It is comprehensive, and usually kept fully up to date.

The correct way to do what you want is to use the SCI_GETFIRSTVISIBLELINE message to get the first line, and then use the SCI_LINESONSCREEN message to calculate the last line.

There are probably Scintilla.NET wrapper methods for those messages. But the Scintilla.NET documentation seems very poor, and doesn't provide a complete description of its API - although I suppose you could always use the SendMessageDirect method (which is documented) to send the messages directly if you can't guess what the wrapper method is called.

其他提示

For ScintillaNET 2 it would be:

scintilla.Lines.FirstVisibleIndex
scintilla.Lines.VisibleCount

In ScintillaNET 3 names were refactored to be more like core scintilla:

scintilla.FirstVisibleLine
scintilla.LinesOnScreen
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top