返回已索引的 Command 对象。
命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)
语法
声明
Function Item ( _
    index As Object, _
    ID As Integer _
) As Command
Command Item(
    Object index,
    int ID
)
Command^ Item(
    [InAttribute] Object^ index, 
    [InAttribute] int ID
)
abstract Item : 
        index:Object * 
        ID:int -> Command 
function Item(
    index : Object, 
    ID : int
) : Command
参数
- index
 类型:System.Object
 必选。绝对索引、GUID 字符串或命令的全称。
- ID
 类型:System.Int32
 可选。指定的命令集中的命令 ID。
返回值
类型:EnvDTE.Command
一个 Command 对象。
备注
如果 index 是一个绝对索引(Long 型),则其只对重复从 1 到 n 的命令有意义。 不能通过保存命令的绝对索引,随后使用该索引来访问该命令。
如果 index 是 GUID 字符串,则它指示一个命令集,并且您必须提供 ID 参数来标识该集中的命令。
如果提供了 ID 参数且第一个参数为字符串,则 index 参数必须为标识命令集的 GUID 字符串。 如果 index 为字符串且没有 ID 参数,则 index 必须为命令的全名。 如果 index 是 Long 型,则 ID 被忽略。
示例
' Macro code.
Sub ItemExample()
   Dim cmds As Commands
   Dim cmd As Command
   ' Set references to the Commands collection and the File.NewFile 
   ' command.
   cmds = DTE.Commands
   cmd = cmds.Item("File.NewFile")
   ' Assign the command (File.NewFile) globally to the F2 key.
   ' Because you cannot programmatically change the default keyboard 
   ' mapping scheme settings, you must first make a copy of the Default 
   ' Settings for the Keyboard Mapping Scheme.
   cmd.Bindings = "Global::f2"
End Sub
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。