Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
TextRanges Interface
Collapse the table of content
Expand the table of content

TextRanges Interface

Contains a TextRange object for each of the tagged subexpressions from a search pattern. TextRanges is also used to find where a box selection intersects each line of text.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

[GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")] 
public interface TextRanges : IEnumerable
/** @attribute GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303") */ 
public interface TextRanges extends IEnumerable
GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303") 
public interface TextRanges extends IEnumerable

A TextRanges collection is returned from a search operation when the search pattern is a regular expression with tagged subexpressions. The TextRanges collection contains a TextRange object for each of the tagged subexpressions.

Also, TextRanges are used to get box selections from the TextSelection object if you need to determine where the box selection intersects each line.

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 ("*/");
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft