表示项目中的项。
命名空间:  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 类型公开以下成员。
属性
| 名称 | 说明 | |
|---|---|---|
| .gif) | Collection | 获取一个 ProjectItems 集合,该集合包含支持此属性的 ProjectItem 对象。 | 
| .gif) | ConfigurationManager | 获取此 ProjectItem 的 ConfigurationManager 对象。 | 
| .gif) | ContainingProject | 获取承载 ProjectItem 的项目。 | 
| .gif) | Document | 获取与项关联的 Document(如果有的话)。 | 
| .gif) | DTE | 获取顶级扩展性对象。 | 
| .gif) | Extender | 如果请求的 Extender 可用于此对象,则获取它。 | 
| .gif) | ExtenderCATID | 获取对象的扩展程序类别 ID (CATID)。 | 
| .gif) | ExtenderNames | 获取此对象的可用扩展程序的列表。 | 
| .gif) | FileCodeModel | 获取项目项的 FileCodeModel 对象。 | 
| .gif) | FileCount | 获取与 ProjectItem 关联的文件数。 | 
| .gif) | FileNames | 获取与项目项关联的文件的完整路径和名称。 | 
| .gif) | IsDirty | 基础结构。仅由 Microsoft 内部使用。 | 
| .gif) | IsOpen | 获取一个值,该值指示项目项是否以特定视图类型打开。 | 
| .gif) | Kind | 获取一个指示对象种类或类型的 GUID 字符串。 | 
| .gif) | Name | 获取或设置对象的名称。 | 
| .gif) | Object | 获取在运行时可通过名称访问的对象。 | 
| .gif) | ProjectItems | 获取对象的 ProjectItems。 | 
| .gif) | Properties | 获取一个属于该对象的所有属性的集合。 | 
| .gif) | Saved | 获取或设置一个值,该值指示对象自上次保存或打开之后是否已修改。 | 
| .gif) | SubProject | 如果该项目项是子项目的根,则 SubProject 属性返回子项目的 Project 对象。 | 
页首
方法
| 名称 | 说明 | |
|---|---|---|
| .gif) | Delete | 从项的项目和存储中移除该项。 | 
| .gif) | ExpandView | 展开“解决方案资源管理器”视图以显示项目项。 | 
| .gif) | Open | 在指定视图中打开 ProjectItem。 | 
| .gif) | Remove | 从集合中移除项目项。 | 
| .gif) | Save | 保存项目或项目项。 | 
| .gif) | 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