Projects.Item Method

Returns an indexed member of a Projects collection.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
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

Parameters

  • index
    Type: System.Object

    Required. The index of the item to return.

Return Value

Type: EnvDTE.Project
A Project object.

Remarks

The value passed to index is an integer that is an index to a Project object in its collection. The value of index can alternatively be a string value that equates to the name of a project in the collection.

The Item method throws a ArgumentException exception if the collection cannot find the object that corresponds to the index value.

Examples

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 Security

See Also

Reference

Projects Interface

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples