Share via


TextRange (Interfaz)

Actualización: noviembre 2007

Representa una única sección contigua de texto en un documento de texto.

Espacio de nombres:  EnvDTE
Ensamblado:  EnvDTE (en EnvDTE.dll)

Sintaxis

<GuidAttribute("72767524-E3B3-43D0-BB46-BBE1D556A9FF")> _
Public Interface TextRange

Dim instance As TextRange
[GuidAttribute("72767524-E3B3-43D0-BB46-BBE1D556A9FF")]
public interface TextRange
[GuidAttribute(L"72767524-E3B3-43D0-BB46-BBE1D556A9FF")]
public interface class TextRange
public interface TextRange

Comentarios

La sección de texto se incluye entre un par de objetos EditPoint.

Los objetos TextRange se utilizan cuando existen expresiones regulares con subexpresiones etiquetadas. Se devuelve una colección de intervalos, uno por cada subexpresión coincidente, y sus propiedades son de sólo lectura.

Para la manipulación general del texto, es más recomendable utilizar objetos como TextSelection o EditPoint, ya que el objeto TextSelection está directamente relacionado con la selección visible en la pantalla. Cuando el área de selección cambia, también cambian las coordenadas del objeto y viceversa. En definitiva, una selección de texto no se puede utilizar para representar un intervalo arbitrario de texto sin alterar dicha selección.

Ejemplos

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

Vea también

Referencia

TextRange (Miembros)

EnvDTE (Espacio de nombres)