Condividi tramite


Metodo Projects.Item

Restituisce un membro indicizzato di un insieme Projects.

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.L'indice dell'elemento da restituire.

Valore restituito

Tipo: EnvDTE.Project
Un oggetto Project.

Note

Il valore passato a index è un intero che corrisponde a un indice di un oggetto Project nel relativo insieme. In alternativa il valore di index può essere un valore stringa corrispondente al nome di un progetto nell'insieme.

Il metodo Item genera un'eccezione ArgumentException se l'insieme non riesce a 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