Projects.Item メソッド

更新 : 2007 年 11 月

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

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

構文

'宣言
Function Item ( _
    index As Object _
) As Project
'使用
Dim instance As Projects
Dim index As Object
Dim returnValue As Project

returnValue = instance(index)
Project Item(
    Object index
)
Project^ Item(
    [InAttribute] Object^ index
)
function Item(
    index : Object
) : Project

パラメータ

  • index
    型 : System.Object

    必ず指定します。返すアイテムのインデックス。

戻り値

型 : EnvDTE.Project

Project オブジェクト。

解説

index に渡される値は、コレクション内の Project オブジェクトへのインデックスである整数です。index の値は、コレクション内のプロジェクトの名前を表す文字列値の場合もあります。

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

public void CodeExample(DTE2 dte)
{  
    try
    {   // Open a project before running this sample
        Projects prjs = dte.Solution.Projects;
        string msg = "There are " + prjs.Count.ToString() + " projects in this collection.";
        msg += "\nThe application containing this Projects collection: " + prjs.DTE.Name;
        msg += "\nThe parent object of the Projects collection: " + prjs.Parent.Name;
        msg += "\nThe GUID representing the Projects type: " + prjs.Kind;
        if (prjs.Properties != null)
        {
            msg += "\nProperties:";
            foreach (Property prop in prjs.Properties)
            {
                msg += "\n   " + prop.Name;
            }
        }
        MessageBox.Show(msg, "Projects Collection");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

アクセス許可

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

参照

参照

Projects インターフェイス

Projects メンバ

EnvDTE 名前空間

その他の技術情報

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