共用方式為


TextSelection.AnchorPoint 屬性

更新:2007 年 11 月

取得選取範圍的原點。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

ReadOnly Property AnchorPoint As VirtualPoint

Dim instance As TextSelection
Dim value As VirtualPoint

value = instance.AnchorPoint
VirtualPoint AnchorPoint { get; }
property VirtualPoint^ AnchorPoint {
    VirtualPoint^ get ();
}
function get AnchorPoint () : VirtualPoint

屬性值

型別:EnvDTE.VirtualPoint

VirtualPoint 物件。

備註

雖然 TextPoint 物件會指出 [編輯器] 視窗中所選擇文字的位置,但是這些物件並不會標記出在緩衝區中的位置。虛擬空間 (在行結尾之外的區域) 也只能在 [編輯器] 視窗中追蹤。結果,當您使用在文字緩衝區中的 EditPoint 來修改文字時,所選擇的文字會發生那些狀況並未定義。例如,某個命令可能以選擇的文字開始、取得編輯點,然後變更緩衝區。若要確保所選的文字會確實在特定位置中,必須將所選的文字明確放置在命令結尾的該位置上。

範例

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

使用權限

請參閱

參考

TextSelection 介面

TextSelection 成員

EnvDTE 命名空間