ProjectItem.ContainingProject Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the project hosting the ProjectItem.
public:
property EnvDTE::Project ^ ContainingProject { EnvDTE::Project ^ get(); };
C++/CX
public:
property EnvDTE::Project ^ ContainingProject { EnvDTE::Project ^ get(); };
[System.Runtime.InteropServices.DispId(121)]
public EnvDTE.Project ContainingProject { [System.Runtime.InteropServices.DispId(121)] get; }
[<System.Runtime.InteropServices.DispId(121)>]
[<get: System.Runtime.InteropServices.DispId(121)>]
member this.ContainingProject : EnvDTE.Project
Public ReadOnly Property ContainingProject As Project
A Project object.
- Attributes
VB
Sub ContainingProjectExample(ByVal dte As DTE2)
' Before running this example, open a code document from a project.
Try
' Create a new namespace.
Dim projItem As ProjectItem = dte.ActiveDocument.ProjectItem
Dim cm As CodeModel = projItem.ContainingProject.CodeModel
cm.AddNamespace("TestNamespace", projItem.Name)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
public void ContainingProjectExample(DTE2 dte)
{
// Before running this example, open a code document from
// a project.
try
{
// Create a new namespace.
ProjectItem projItem = dte.ActiveDocument.ProjectItem;
CodeModel cm = projItem.ContainingProject.CodeModel;
cm.AddNamespace("TestNamespace", projItem.Name, -1);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Produkt | Versiounen |
---|---|
Visual Studio SDK | 2015, 2017, 2019, 2022 |