Partager via


VSProjectItem.ProjectItem Property

Gets the ProjectItem object associated with the given object.

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

Syntax

'Declaration
ReadOnly Property ProjectItem As ProjectItem
ProjectItem ProjectItem { get; }
property ProjectItem^ ProjectItem {
    ProjectItem^ get ();
}
abstract ProjectItem : ProjectItem with get
function get ProjectItem () : ProjectItem

Property Value

Type: EnvDTE.ProjectItem
Returns a ProjectItem object.

Examples

Sub PrjItem(ByVal dte As DTE2)
    ' List the name of the first VSProjectItem.
    ' Before running, open a VB or C# application in VS.
    Dim vsPrj As VSProject = _
    CType(dte.Solution.Projects.Item(1).Object, VSProject)
    Dim vsPrjItem As VSProjectItem

    vsPrjItem = CType(dte.Solution.Projects.Item(1) _
    .ProjectItems.Item(1).Object, VSProjectItem)
    MsgBox("Proj Item Name: " & vsPrjItem.ProjectItem.Name)
End Sub
public void PrjItem(DTE2 dte)
{
    // List the name of the first VSProjectItem.
    // Before running, open a VB or C# application in VS.
    VSProject vsPrj = (VSProject)dte.Solution.Projects.Item(1).Object;
    VSProjectItem vsPrjItem;

    vsPrjItem = (VSProjectItem)dte.Solution.Projects.Item(1).
    ProjectItems.Item(1).Object;
    MessageBox.Show("Proj Item Name: " + vsPrjItem.ProjectItem.Name);
}

.NET Framework Security

See Also

Reference

VSProjectItem Interface

VSLangProj Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples