Share via


ProjectItem 介面

代表專案中的一個項目。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
<GuidAttribute("0B48100A-473E-433C-AB8F-66B9739AB620")> _
Public Interface ProjectItem
[GuidAttribute("0B48100A-473E-433C-AB8F-66B9739AB620")]
public interface ProjectItem
[GuidAttribute(L"0B48100A-473E-433C-AB8F-66B9739AB620")]
public interface class ProjectItem
[<GuidAttribute("0B48100A-473E-433C-AB8F-66B9739AB620")>]
type ProjectItem =  interface end
public interface ProjectItem

ProjectItem 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Collection 取得包含支援此屬性之 ProjectItem 物件的 ProjectItems 集合。
公用屬性 ConfigurationManager 取得這個 ProjectItem 的 ConfigurationManager 物件。
公用屬性 ContainingProject 取得裝載 ProjectItem 的專案。
公用屬性 Document 取得與這項目關聯的 Document (如果有的話)。
公用屬性 DTE 取得最上層的擴充性物件。
公用屬性 Extender 取得要求的 Extender (如果適用於這個物件)。
公用屬性 ExtenderCATID 取得物件的擴充項分類 ID (CATID)。
公用屬性 ExtenderNames 取得物件的可用擴充項清單。
公用屬性 FileCodeModel 取得專案項目的 FileCodeModel 物件。
公用屬性 FileCount 取得與 ProjectItem 關聯的檔案數量。
公用屬性 FileNames 取得與專案項目相關的檔案完整路徑和檔名。
公用屬性 IsDirty 基礎架構。僅限 Microsoft 內部使用。
公用屬性 IsOpen 取得值,表示專案項目是否以特定的檢視類型開啟。
公用屬性 Kind 取得指示物件種類或型別的 GUID 字串。
公用屬性 Name 取得或設定物件的名稱。
公用屬性 Object 取得物件,此物件可在執行階段中以名稱存取。
公用屬性 ProjectItems 取得物件的 ProjectItems
公用屬性 Properties 取得與該物件有關的所有屬性的集合。
公用屬性 Saved 取得或設定一個值,表示物件自上一次儲存或開啟後,是否曾被修改。
公用屬性 SubProject 如果專案項目是子專案的根 (Root),SubProject 屬性就會對子專案傳回 Project 物件。

回頁首

方法

  名稱 說明
公用方法 Delete 將項目從它的專案和儲存區移除。
公用方法 ExpandView 展開 [方案總管] 的檢視,以顯示專案項目。
公用方法 Open 在指定的檢視中開啟 ProjectItem。
公用方法 Remove 從集合中移除專案項目。
公用方法 Save 儲存專案或專案項目。
公用方法 SaveAs 儲存專案項目。

回頁首

範例

' 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 命名空間

其他資源

控制專案與方案