TextRanges 接口

更新:2007 年 11 月

对于搜索模式中的每个带标记子表达式,都包含一个 TextRange 对象。TextRanges 也用于查找选择框与每一行文本相交于何处。

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

语法

声明
<GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")> _
Public Interface TextRanges _
    Implements IEnumerable
用法
Dim instance As TextRanges
[GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")]
public interface TextRanges : IEnumerable
[GuidAttribute(L"B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")]
public interface class TextRanges : IEnumerable
public interface TextRanges extends IEnumerable

备注

当搜索模式是具有带标记子表达式的正则表达式时,搜索操作返回 TextRanges 集合。TextRanges 集合包含对应于每一个带标记子表达式的 TextRange 对象。

此外,如果需要确定选择框与每一行相交于何处,也可使用 TextRanges 从 TextSelection 对象获取选择框。

示例

Sub TextRangeExample(ByVal dte As EnvDTE.DTE)
    Dim objTxtSel As TextSelection
    Dim colRanges As TextRanges
    Dim objRange As TextRange
    Dim objEP As EditPoint

    objTxtSel = dte.ActiveDocument.Selection
    colRanges = objTxtSel.TextRanges
    For Each objRange In colRanges
        objRange.StartPoint.Insert("/*")
        objRange.EndPoint.Insert("*/")
    Next
End Sub
public void TextRangeExample(_DTE dte)
{
    TextSelection ts;
    TextRanges trs;

    ts = (TextSelection)dte.ActiveDocument.Selection;
    trs = ts.TextRanges;
    MessageBox.Show (trs.Count.ToString ());
    foreach (TextRange tr in trs)
    {
        tr.StartPoint.Insert ("/*");
        tr.EndPoint.Insert ("*/");
    }
}

另请参见

参考

TextRanges 成员

EnvDTE 命名空间