Share via


ProjectItems.Item 方法

返回 ProjectItems 集合中的一个 ProjectItem 对象。

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

语法

声明
Function Item ( _
    index As Object _
) As ProjectItem
ProjectItem Item(
    Object index
)
ProjectItem^ Item(
    [InAttribute] Object^ index
)
abstract Item : 
        index:Object -> ProjectItem
function Item(
    index : Object
) : ProjectItem

参数

  • index
    类型:Object

    必选。 要返回的 ProjectItem 对象的索引。

返回值

类型:EnvDTE.ProjectItem
一个 ProjectItem 对象。

备注

传递给 Index 的值可以是一个整数(该整数是 ProjectItems 集合中的 ProjectItem 对象的索引),也可以是该集合中的 ProjectItem 对象的 UniqueName

如果集合无法找到对应于索引或 UniqueName 值的对象,则 Item 方法会引发 ArgumentException 异常。

示例

' Before running, create a solution with an empty project named 
' "Project1".
Sub ThrowArgumentException()
    ' Projects of the current solution.
    Dim cprojects As Projects = DTE.Solution.Projects   
    Dim project1 As Project = cprojects.Item(1)
    Debug.Assert(cprojects.Item(project1.UniqueName) Is project1)
End Sub

.NET Framework 安全性

请参阅

参考

ProjectItems 接口

EnvDTE 命名空间

其他资源

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