This documentation is archived and is not being maintained.

AnchorPoint Property

Visual Studio .NET 2003

Returns the origin point of the selection.

[Visual Basic .NET]
Public ReadOnly Property AnchorPoint() As VirtualPoint
[Visual Basic 6]
Property Get AnchorPoint() As VirtualPoint
[C++]
HRESULT __stdcall get_AnchorPoint(
   /* [out, retval] */ VirtualPoint** retVal
);
[C#]
public VirtualPoint AnchorPoint {get;}
[JScript .NET]
public function get AnchorPoint() : VirtualPoint

Return Value

Returns a VirtualPoint object.

Remarks

Although TextPoint Objects indicate the location of the selected text in the Editor window, they don't mark the location in the buffer. Virtual spacethe area beyond the end of the lineis also tracked only in the Editor window. Because of this, when you use an EditPoint Object in the text buffer to modify text, what happens to the selected text is not defined. If you have a command that starts with selected text, gets edit points, then changes the buffer, and you need to guarantee the selected text is in a certain location, you must explicitly place the selected text in that location at the end of your command.

Example

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

See Also

Applies To: TextSelection Object

Show: