TextSelection.ActivePoint 属性

更新:2007 年 11 月

获取选定内容的当前终结点。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
ReadOnly Property ActivePoint As VirtualPoint
用法
Dim instance As TextSelection
Dim value As VirtualPoint

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

属性值

类型:EnvDTE.VirtualPoint

一个 VirtualPoint 对象。

备注

虽然 TextPoint 对象指示“编辑器”窗口中选定文本的位置,但这些对象并不标记缓冲区中的位置。虚空格(超出行尾的区域)也只在“编辑器”窗口中才被跟踪。因此,当在文本缓冲区中使用 EditPoint 对象修改文本时,对选定文本的操作结果是不确定的。例如,命令可能会从选定文本开始,获取编辑点,然后再更改缓冲区。为了保证选定文本位于特定位置,必须将选定文本显式放在命令结尾处。

示例

Sub ActivePointExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   Dim objActive As VirtualPoint = objSel.ActivePoint
   ' Collapse the selection to the beginning of the line.
   objSel.StartOfLine()
   ' objActive is "live", tied to the position of the actual selection, 
   ' so it will reflect the new position.
   Dim iCol As Long = objActive.DisplayColumn
   ' Move the selection to the end of the line.
   objSel.EndOfLine()

   MsgBox("The length of the insertion point line is " & (objActive.DisplayColumn - iCol) & " display characters.")
End Sub

权限

另请参见

参考

TextSelection 接口

TextSelection 成员

EnvDTE 命名空间