|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Assembly: EnvDTE (in envdte.dll)
Visual Studio allows for some projects, such as Enterprise Templates projects, to include other projects as items, specifically, as subprojects. Each of those projects is a template for an enterprise application, and it includes Visual Basic and Visual C++ subprojects. If you have such a project interface or wrapped project, then ParentProjectItem returns the ProjectItem object for the item in the template project that is the wrapped project.
Sub ParentProjectItemExample() Dim proj As Project Dim projitems As ProjectItems Dim msg As String ' Reference the current solution and its projects and project items. proj = DTE.ActiveSolutionProjects(0) projitems = proj.ProjectItems ' List properties of the project and its items. msg = "Is the item open? " & projitems.Item(1).IsOpen & Chr(13) msg = msg & "The project's unique name: " & proj.UniqueName ' The following two properties work only if the current project ' contains subprojects. If it does, then uncomment the lines to run ' them. ' msg = msg & "The parent project item name: " & proj.ParentProjectItem.Name & Chr(13) ' msg = msg & "The subproject name: " & projitems.Item(1).SubProject.Name & Chr(13) MsgBox(msg) End Sub