TextPane2 介面

代表一個文字編輯器視窗內的窗格。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
<GuidAttribute("ACE19C7B-A0AC-4089-94FD-749CF4380E1F")> _
Public Interface TextPane2 _
    Inherits TextPane
[GuidAttribute("ACE19C7B-A0AC-4089-94FD-749CF4380E1F")]
public interface TextPane2 : TextPane
[GuidAttribute(L"ACE19C7B-A0AC-4089-94FD-749CF4380E1F")]
public interface class TextPane2 : TextPane
[<GuidAttribute("ACE19C7B-A0AC-4089-94FD-749CF4380E1F")>]
type TextPane2 =  
    interface
        interface TextPane
    end
public interface TextPane2 extends TextPane

TextPane2 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Collection (繼承自 TextPane)。
公用屬性 Collection 取得包含支援此屬性之 TextPane 物件的集合。
公用屬性 DTE (繼承自 TextPane)。
公用屬性 DTE 取得最上層的擴充性物件。
公用屬性 Height (繼承自 TextPane)。
公用屬性 Height 取得文字窗格的高度,以字元為單位。
公用屬性 IncrementalSearch 提供文字編輯器累加搜尋 (ISearch) 功能的存取。
公用屬性 Selection (繼承自 TextPane)。
公用屬性 Selection 取得物件,表示 TextPane 物件上目前的選取範圍。
公用屬性 StartPoint (繼承自 TextPane)。
公用屬性 StartPoint 取得 TextPoint 物件,表示窗格的第一個顯示字元。
公用屬性 Width (繼承自 TextPane)。
公用屬性 Width 取得文字窗格的寬度,以字元為單位。
公用屬性 Window (繼承自 TextPane)。
公用屬性 Window 取得 Window 物件,此物件包含已指定的窗格。

回頁首

方法

  名稱 說明
公用方法 Activate() (繼承自 TextPane)。
公用方法 Activate() 將焦點移至目前的項目。
公用方法 IsVisible(TextPoint, Object) (繼承自 TextPane)。
公用方法 IsVisible(TextPoint, Object) 傳回數值,指出字元或指定字元在文字窗格中是否為可見的。
公用方法 TryToShow(TextPoint, vsPaneShowHow, Object) (繼承自 TextPane)。
公用方法 TryToShow(TextPoint, vsPaneShowHow, Object) 調整文字緩衝區中文字檢視的位置,如果可能的話,讓選取的文字範圍顯示在文字窗格中。您可以控制文字在窗格中的顯示位置。

回頁首

備註

您可以將一個文字編輯器視窗分割成兩個窗格。 TextPane 物件可讓您存取每一窗格中的選取文字,以及窗格的屬性,例如高度、寬度等。

範例

這個範例會開啟文字文件,並在訊息方塊中顯示某些文字窗格屬性。 如需如何像執行增益集一般,執行這個範例的詳細資訊,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    TextPane2Example(_applicationObject)
End Sub
Sub TextPane2Example(ByVal dte As DTE2)
    Dim objTW As TextWindow
    Dim objPane As TextPane2
    Dim objStart As TextPoint
    Dim objTextDoc As TextDocument
    Dim objTextPt As TextPoint
    Dim objEP As EditPoint
    ' Create a new text document.
    _applicationObject.ItemOperations.NewFile("General\Text File")
    ' Get a handle to the new document and create EditPoint,
    ' TextPoint, and TextPane2 objects.
    objTextDoc = CType(_applicationObject.ActiveDocument.Object _
    ("TextDocument"), TextDocument)
    objEP = objTextDoc.StartPoint.CreateEditPoint
    objTextPt = objTextDoc.StartPoint
    ' Plug in some text.
    objEP.Insert("A test sentence.")
    objTW = CType(dte.ActiveWindow.Object, TextWindow)
    objPane = CType(objTW.ActivePane, TextPane2)
    MsgBox("The active pane is " & Str(objPane.Height)  _
    & " lines high and " & Str(objPane.Width) & " columns wide.")
    objStart = objPane.StartPoint
    MsgBox("It begins at line " & Str(objStart.Line) & ", column " & _
     Str(objStart.LineCharOffset) & ".")
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    TextPane2Example(_applicationObject);
}
public void TextPane2Example(DTE2 dte)
{
    TextWindow objTW;
    TextPane2 objPane;
    TextPoint objStart;
    TextDocument objTextDoc;
    TextPoint objTextPt;
    EditPoint2 objEP;
    // Create a new text document.
    _applicationObject.ItemOperations.NewFile(@"General\Text File",
 "test.txt", Constants.vsViewKindTextView);
    // Get a handle to the text document and create EditPoint2,
    // TextPoint, and TextPane2 objects.
    objTextDoc =(TextDocument)_applicationObject.ActiveDocument.Object
("TextDocument");
    objEP = (EditPoint2)objTextDoc.StartPoint.CreateEditPoint();
    objTextPt = objTextDoc.StartPoint;
    // Plug in some text.
    objEP.Insert("A test sentence.");
    objTW = (TextWindow)_applicationObject.ActiveWindow.Object;
    objPane = (TextPane2)objTW.ActivePane;
    MessageBox.Show("The active pane is " + objPane.Height + " 
lines high and " + objPane.Width + " columns wide.");
    objStart = objPane.StartPoint;
    MessageBox.Show("It begins at line " + objStart.Line 
+ ", column " +  objStart.LineCharOffset + ".");
}

請參閱

參考

EnvDTE80 命名空間