Partager via


TextSelection.AnchorPoint, propriété

Obtient le point d'origine de la sélection.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
ReadOnly Property AnchorPoint As VirtualPoint
    Get
VirtualPoint AnchorPoint { get; }
property VirtualPoint^ AnchorPoint {
    VirtualPoint^ get ();
}
abstract AnchorPoint : VirtualPoint
function get AnchorPoint () : VirtualPoint

Valeur de propriété

Type : EnvDTE.VirtualPoint
Objet VirtualPoint.

Notes

Bien que les objets TextPoint indiquent l'emplacement du texte sélectionné dans la fenêtre Éditeur, ils ne marquent pas l'emplacement dans la mémoire tampon. L'espace virtuel (zone au-delà de la fin de la ligne) n'est donc repérable que dans la fenêtre Éditeur. Par conséquent, lorsque vous utilisez EditPoint dans la mémoire tampon de texte pour modifier du texte, ce qui arrive au texte sélectionné n'est pas défini. Par exemple, une commande peut commencer avec du texte sélectionné, avoir des points d'édition, puis modifier la mémoire tampon. Pour garantir que le texte sélectionné se trouve à un certain emplacement, vous devez explicitement le mettre à cet emplacement à la fin de votre commande.

Exemples

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

Sécurité .NET Framework

Voir aussi

Référence

TextSelection Interface

EnvDTE, espace de noms