VSProjectItem.ProjectItem 属性

获取与给定对象关联的 ProjectItem 对象。

命名空间:  VSLangProj
程序集:  VSLangProj(在 VSLangProj.dll 中)

语法

声明
ReadOnly Property ProjectItem As ProjectItem
ProjectItem ProjectItem { get; }
property ProjectItem^ ProjectItem {
    ProjectItem^ get ();
}
abstract ProjectItem : ProjectItem
function get ProjectItem () : ProjectItem

属性值

类型:EnvDTE.ProjectItem
返回 ProjectItem 对象。

示例

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 安全性

请参见

参考

VSProjectItem 接口

VSLangProj 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例