次の方法で共有


TextPane2.TryToShow メソッド (TextPoint, vsPaneShowHow, Object)

可能な場合に、指定されたテキスト範囲がテキスト ペイン内に表示されるように、テキスト バッファー内のビューの位置を調整します。ペインでのテキストの表示位置を制御できます。

名前空間:  EnvDTE80
アセンブリ:  EnvDTE80 (EnvDTE80.dll 内)

構文

'宣言
Function TryToShow ( _
    Point As TextPoint, _
    How As vsPaneShowHow, _
    PointOrCount As Object _
) As Boolean
bool TryToShow(
    TextPoint Point,
    vsPaneShowHow How,
    Object PointOrCount
)
bool TryToShow(
    [InAttribute] TextPoint^ Point, 
    [InAttribute] vsPaneShowHow How, 
    [InAttribute] Object^ PointOrCount
)
abstract TryToShow : 
        Point:TextPoint * 
        How:vsPaneShowHow * 
        PointOrCount:Object -> bool 
function TryToShow(
    Point : TextPoint, 
    How : vsPaneShowHow, 
    PointOrCount : Object
) : boolean

パラメーター

  • PointOrCount
    型 : System.Object
    省略可能です。表示するテキスト範囲の終わりを表すバリアントです。 PointOrCount が複数の文字である場合は、その文字列が Point の後に続きます。 PointOrCount が Point の前のポイントである場合、How が vsPaneShowTop に設定されると、そのポイントはテキスト ペインの上部に表示されます。
    How に vsPaneShowCentered が設定され、選択されているテキストの行数がペインの高さを超える場合は、選択されているテキストの一番上の行がペインの上部に配置されます。

戻り値

型 : System.Boolean
テキストを表示できる場合は true を返します。それ以外の場合は false を返します。

この例では、テキスト ドキュメントを開き、テキストを表示してから、TextPane2TryToShow メソッドを使用して、テキスト ペインを含むウィンドウを表示します。このアドインの例を実行する方法の詳細については、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」を参照してください。

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)
    TextPane2TryToShowExample(_applicationObject)
End Sub
Sub TextPane2TryToShowExample(ByVal dte As DTE2)
    Dim objTW As TextWindow
    Dim objPane As TextPane2
    Dim objTextDoc As TextDocument
    Dim objTextPt As TextPoint
    Dim objEP As EditPoint
    Dim objStart As TextPoint
    ' Create a new text document.
    _applicationObject.ItemOperations.NewFile("General\Text File")
    ' Get a handle to the new document and create EditPoint,
    ' TextPoint, and TextPane 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) & ".")
    MsgBox("Using TryToShow to center the pane...")
    objPane.TryToShow(objStart, vsPaneShowHow.vsPaneShowCentered)
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;
    TextPane2TryToShowExample(_applicationObject);
}
public void TextPane2TryToShowExample(DTE2 dte)
{
    TextWindow objTW;
    TextPane2 objPane;
    TextDocument objTextDoc;
    TextPoint objTextPt;
    EditPoint2 objEP;
    TextPoint objStart;
    // 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 + ".");
    MessageBox.Show("Using TryToShow to show the pane as centered...");
    objPane.TryToShow(objStart, vsPaneShowHow.vsPaneShowCentered, 2);
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

TextPane2 インターフェイス

TryToShow オーバーロード

EnvDTE80 名前空間