Reference.ContainingProject Property

Definition

Gets the project that the selected item is a part of. Read-only.

public:
 property EnvDTE::Project ^ ContainingProject { EnvDTE::Project ^ get(); };
public:
 property EnvDTE::Project ^ ContainingProject { EnvDTE::Project ^ get(); };
[System.Runtime.InteropServices.DispId(3)]
public EnvDTE.Project ContainingProject { [System.Runtime.InteropServices.DispId(3)] get; }
[<System.Runtime.InteropServices.DispId(3)>]
[<get: System.Runtime.InteropServices.DispId(3)>]
member this.ContainingProject : EnvDTE.Project
Public ReadOnly Property ContainingProject As Project

Property Value

Returns a Project object.

Attributes

Examples

This example demonstrates using a private macro function to retrieve the name of the project of which the selected project item is a part. 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  

Remarks

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

Applies to