更新: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
属性值
一个 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
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。