次の方法で共有


Windows2.Item メソッド (Object)

Windows コレクションのインデックス付きメンバーを返します。

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

構文

'宣言
Function Item ( _
    index As Object _
) As Window
Window Item(
    Object index
)
Window^ Item(
    [InAttribute] Object^ index
)
abstract Item : 
        index:Object -> Window 
function Item(
    index : Object
) : Window

パラメーター

  • index
    型: System.Object
    必ず指定します。返すアイテムのインデックス。

戻り値

型: EnvDTE.Window
Window オブジェクト。

実装

Windows.Item(Object)

解説

Index に渡される値は、コレクション内のオブジェクトへのインデックスである整数値です。 ただし、多くのオブジェクトは、Index の値としてコレクション内のオブジェクトを表す文字列値を指定できます。 ただし、Item によって受け入れられる正確な値は、コレクションとその実装によって異なります。

Item メソッドは、コレクションがインデックス値に対応するオブジェクトを見つけられない場合に ArgumentException 例外をスローします。

この例では、Windows2 コレクションのすべての項目のキャプションを表示します。

このアドインの例を実行する方法の詳細については、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」を参照してください。

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)
    IterateItems(_applicationObject)
End Sub
Sub IterateItems(ByVal dte As DTE2)
    Dim win As Windows2
    win = CType(_applicationObject.Windows, EnvDTE80.Windows2)
    Dim aString As String
    aString = ""
    Dim count As Integer
    count = win.Count
    Dim i As Integer
    For i = 1 To count Step 1
        aString = aString & "The window number " & i & _
 " in the collection, has the caption: " & win.Item(i).Caption & vbCr
    Next
    MsgBox(aString)
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;
    IterateItems(_applicationObject);
}
public void IterateItems(DTE2 dte)
{
    Windows2 win;
    win = (EnvDTE80.Windows2)_applicationObject.Windows;
    int count = win.Count;
    String aString = null;
    for (int i = 1; i <= count; i++ )
    {
        aString = aString + ("The window number " + i + 
" in the collection, has the caption: " + win.Item(i).Caption + "\n");
    }
    MessageBox.Show(aString);
}

.NET Framework セキュリティ

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

参照

参照

Windows2 インターフェイス

Item オーバーロード

EnvDTE80 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する