TextRange الواجهة

يمثل أداة متجاورة مقطع نص في مستند نصي.

مساحة الاسم:  EnvDTE
التجميع:  EnvDTE (في EnvDTE.dll)

بناء الجملة

'إقرار
<GuidAttribute("72767524-E3B3-43D0-BB46-BBE1D556A9FF")> _
Public Interface TextRange
[GuidAttribute("72767524-E3B3-43D0-BB46-BBE1D556A9FF")]
public interface TextRange
[GuidAttribute(L"72767524-E3B3-43D0-BB46-BBE1D556A9FF")]
public interface class TextRange
[<GuidAttribute("72767524-E3B3-43D0-BB46-BBE1D556A9FF")>]
type TextRange =  interface end
public interface TextRange

ملاحظات

هو للمقطع من نص المحاط بزوج من EditPointالكائنات.

TextRangeيتم استخدام الكائنات عندما يكون لديك التعابير النظامية مع subexpressions ذات العلامات. مجموعة من النطاقات هو التي يتم إرجاعها، واحد لكل تطابق subexpression وخصائصها للقراءة فقط.

لمعالجة نص عامة، هو بدلاً من استخدام الكائنات مثل TextSelectionأو EditPoint، لأن TextSelectionالكائن يرتبط مباشرة ب vهوible التحديد تشغيل شاشة. عند تغيير ناحية تحديد وتغيير إحداثيات كائن's والعكس بالعكس. ونتيجة لذلك، لا يمكن استخدام تحديد نص إلى تمثل نطاق إجبارية النص دون إفساد هذا التحديد النص.

أمثلة

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

راجع أيضًَا

المرجع

TextRange الأعضاء

EnvDTE مساحة الاسم