Projects.Item-Methode

Gibt einen indizierten Member einer Projects-Auflistung zurück.

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

Parameter

  • index
    Typ: Object

    Erforderlich. Der Index des zurückzugebenden Elements.

Rückgabewert

Typ: EnvDTE.Project
Ein Project-Objekt.

Hinweise

Der an index übergebene Wert ist eine ganze Zahl, die einen Index für ein Project-Objekt in dessen Auflistung darstellt. Der Wert von index kann alternativ ein Zeichenfolgenwert sein, der dem Namen eines Projekts in der Auflistung entspricht.

Die Item-Methode löst eine ArgumentException-Ausnahme aus, wenn die Auflistung das dem Indexwert entsprechende Objekt nicht finden kann.

Beispiele

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-Sicherheit

Siehe auch

Referenz

Projects Schnittstelle

EnvDTE-Namespace

Weitere Ressourcen

Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell