Megosztás a következőn keresztül:


TextSelection.AnchorPoint Property

Gets the origin point of the selection.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property AnchorPoint As VirtualPoint
VirtualPoint AnchorPoint { get; }
property VirtualPoint^ AnchorPoint {
    VirtualPoint^ get ();
}
abstract AnchorPoint : VirtualPoint with get
function get AnchorPoint () : VirtualPoint

Property Value

Type: EnvDTE.VirtualPoint
A VirtualPoint object.

Remarks

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 in the text buffer to modify text, what happens to the text selection is not defined. For example a command might 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.

Examples

Sub AnchorPointExample()
    ' Before running this example, open a text document.
    Dim objSel As TextSelection = DTE.ActiveDocument.Selection
    Dim objAnchor As VirtualPoint = objSel.AnchorPoint
    ' objAnchor is "live", tied to the position of the actual selection, 
    ' so it will reflect any changes. iCol and iRow are created here to 
    ' save a "snapshot" of the anchor point's position at this time.
    Dim iCol As Long = objAnchor.DisplayColumn
    Dim iRow As Long = objAnchor.Line
    ' As the selection is extended, the active point moves but the anchor 
    ' point remains in place.
    objSel.StartOfDocument(True)
    objSel.EndOfDocument(True)

    If (iCol = objAnchor.DisplayColumn And iRow = objAnchor.Line) Then
        MsgBox("The anchor point has remained in place at row " & iRow & ", display column " & iCol)
    End If
End Sub

.NET Framework Security

See Also

Reference

TextSelection Interface

EnvDTE Namespace