This documentation is archived and is not being maintained.

Project.ProjectItems Property

Gets a ProjectItems collection for the Project object.

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

ProjectItems ProjectItems { get; }
/** @property */
ProjectItems get_ProjectItems ()

function get ProjectItems () : ProjectItems

Property Value

A ProjectItems collection.

The returned collection represents project items that may be hierarchically below the project item.

This example works only in Visual Studio .NET 2003. For more information, see How To: Programmatically Create Projects and What's New in Extensibility and Automation in Visual Studio 2005.

public void ProjectItemsExample(DTE dte)
    // NOTE: This example requires a reference to the 
    //       VSLangProj namespace.

    // Create a new solution.
    Solution soln = dte.Solution;
    string solnName = "NewSolution.sln";
    string tempPath = System.IO.Path.GetTempPath();
    soln.Create(tempPath, solnName);

    // Create a new C# Console Application project.
    string templatePath = 
    templatePath += "CSharpConsole.vsz";
    string projName = "Project1";
    soln.AddFromTemplate(templatePath, tempPath + projName, 
        projName, false);
    Project proj = soln.Item(1);

    // Add a comment to Class1.cs.
    ProjectItem item = proj.ProjectItems.Item("Class1.cs");
    TextSelection sel = (TextSelection)item.Document.Selection;

    sel.LineUp(false, 1);
    sel.Text = "// New comment\n";