TextSelection.TextRanges 属性

为选定内容中的每行或部分行获取包含一个 TextRange 对象的 TextRanges 集合。

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

语法

声明
ReadOnly Property TextRanges As TextRanges
    Get
TextRanges TextRanges { get; }
property TextRanges^ TextRanges {
    TextRanges^ get ();
}
abstract TextRanges : TextRanges
function get TextRanges () : TextRanges

属性值

类型:EnvDTE.TextRanges
一个 TextRanges 集合。

备注

对于选定文本中的每一行,不论其当前模式是什么,都有一个 TextRange 对象表示选定内容中行的有效部分。 当选定内容模式是 Stream 时,TextRange 对象仅表示选定内容中的文本。 如果有些行长于其他行,则只会获取实际包含文本的行的范围。

每次从选定文本检索 TextRanges 集合时,以前的内容都将丢失。

示例

Sub TextRangesExample()
   ' Before running this example, open a code document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   MsgBox("Startpoint line: " & (objSel.TextRanges.Item(1).StartPoint.Line) & vbCr & "Endpoint line: " & (objSel.TextRanges.Item(1).EndPoint.Line))
End Sub

.NET Framework 安全性

请参见

参考

TextSelection 接口

EnvDTE 命名空间