Share via


Imports.ContainingProject Property

Gets the project that contains the selected item. Read-only.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

Syntax

'Declaration
ReadOnly Property ContainingProject As Project
    Get
Project ContainingProject { get; }
property Project^ ContainingProject {
    Project^ get ();
}
abstract ContainingProject : Project
function get ContainingProject () : Project

Property Value

Type: EnvDTE.Project
Returns a Project object.

Remarks

Use this property to retrieve the Project object that includes the item.

Examples

This example demonstrates using a private macro function to retrieve the name of the project that contains the selected project item. A test method is created to use the function.

' Macro Editor 
Imports VSLangProj
Private Function GetProjectName(ByVal refs As References) _
   As String
   Return refs.ContainingProject.Name
End Function
    
Sub TestGetProjectName()
   ' First project is a Visual Basic or C# project.
   Dim theVSProject As VSProject = _
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)
   Dim refs As References = theVSProject.References
   MsgBox(GetProjectName(refs))
End Sub

.NET Framework Security

See Also

Reference

Imports Interface

VSLangProj Namespace