ProjectItems 接口

包含 ProjectItem 对象,每个对象都表示项目中的项。

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

语法

声明
<GuidAttribute("8E2F1269-185E-43C7-8899-950AD2769CCF")> _
Public Interface ProjectItems _
    Inherits IEnumerable
[GuidAttribute("8E2F1269-185E-43C7-8899-950AD2769CCF")]
public interface ProjectItems : IEnumerable
[GuidAttribute(L"8E2F1269-185E-43C7-8899-950AD2769CCF")]
public interface class ProjectItems : IEnumerable
[<GuidAttribute("8E2F1269-185E-43C7-8899-950AD2769CCF")>]
type ProjectItems =  
    interface 
        interface IEnumerable 
    end
public interface ProjectItems extends IEnumerable

ProjectItems 类型公开以下成员。

属性

  名称 说明
公共属性 ContainingProject 获取承载项目项或项的项目。
公共属性 Count 获取一个值,该值指示集合中对象的数目。
公共属性 DTE 获取顶级扩展性对象。
公共属性 Kind 获取一个指示对象类型的枚举。
公共属性 Parent 获取 ProjectItems 集合的直接父对象。

页首

方法

  名称 说明
公共方法 AddFolder “解决方案资源管理器”中创建新文件夹。
公共方法 AddFromDirectory 将一个或多个 ProjectItem 对象从目录添加到 ProjectItems 集合。
公共方法 AddFromFile 从安装在项目目录结构中的文件添加项目项。
公共方法 AddFromFileCopy 复制源文件并将其添加到项目中。
公共方法 AddFromTemplate 在现有项模板文件中创建一个新项目项并将其添加到项目中。
公共方法 GetEnumerator 返回集合中项的枚举。
公共方法 Item 返回 ProjectItems 集合中的一个 ProjectItem 对象。

页首

备注

此集合由级联 ProjectItems 集合的分层(嵌套)结构组成,其中的这些集合分别表示每个项目中的项。

使用 Solution.Item().ProjectItems 引用此集合。

示例

' Before running, create a new project or open an existing project.
Sub ListProj()
   Dim proj As Project = DTE.ActiveSolutionProjects(0)
   Dim win As Window = _
     DTE.Windows.Item(Constants.vsWindowKindCommandWindow)
   ListProjAux(proj.ProjectItems(), 0)
End Sub

Sub ListProjAux(ByVal projitems As ProjectItems, ByVal Level As Integer)
   Dim projitem As ProjectItem
   For Each projitem In projitems
      MsgBox("Project item: " & projitem.Name, Level)
      ' Recurse if the project item has sub-items...
      Dim projitems2 As ProjectItems 
      projitems2 = projitem.ProjectItems
      Dim notsubcoll As Boolean = projitems2 Is Nothing
      If Not notsubcoll Then
         ListProjAux(projitems2, Level + 1)
      End If
   Next
End Sub

请参阅

参考

EnvDTE 命名空间

其他资源

控制项目和解决方案

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