共用方式為


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() 傳回會逐一查看集合的列舉程式。 (繼承自 IEnumerable)。
公用方法 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 命名空間

其他資源

控制專案與方案

HOW TO:編譯和執行 Automation 物件模型程式碼範例