TextSelection::ActivePoint Property
Visual Studio 2015
Gets the current endpoint of the selection.
Assembly: EnvDTE (in EnvDTE.dll)
Although TextPoint objects indicate the location of the text selection in the Editor window, they do not mark the location in the buffer. Virtual space — the area beyond the end of the line — is also tracked only in the Editor window. Consequently, when you use an EditPoint object in the text buffer to modify text, what happens to the text selection is not defined. For example, a command may start with text selection, get edit points, and then change the buffer. To guarantee the text selection is in a certain location, you must explicitly place the text selection in that location at the end of your command.
Sub ActivePointExample() ' Before running this example, open a text document. Dim objSel As TextSelection = DTE.ActiveDocument.Selection Dim objActive As VirtualPoint = objSel.ActivePoint ' Collapse the selection to the beginning of the line. objSel.StartOfLine() ' objActive is "live", tied to the position of the actual selection, ' so it will reflect the new position. Dim iCol As Long = objActive.DisplayColumn ' Move the selection to the end of the line. objSel.EndOfLine() MsgBox("The length of the insertion point line is " & (objActive.DisplayColumn - iCol) & " display characters.") End Sub
Show: