次の方法で共有


Projects.Item メソッド

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

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

構文

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

パラメーター

  • index
    型 : 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);
    }
}

.NET Framework セキュリティ

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

参照

関連項目

Projects インターフェイス

EnvDTE 名前空間

その他の技術情報

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