Condividi tramite


Metodo Projects.Item

Restituisce un membro indicizzato di un oggetto Projects raccolta.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

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

Parametri

  • index
    Tipo: System.Object
    obbligatorio.Indice dell'elemento da restituire.

Valore restituito

Tipo: EnvDTE.Project
In Project oggetto.

Note

il valore passato a index è un Integer che è un indice a un oggetto Project oggetto nella raccolta.il valore di index in alternativa essere un valore stringa che corrisponde al nome di un progetto nella raccolta.

Il metodo genera un'eccezione ArgumentException eccezione se la raccolta impossibile trovare l'oggetto che corrisponde al valore di indice.

Esempi

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);
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Projects Interfaccia

Spazio dei nomi EnvDTE

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione