共用方式為


Commands.Item 方法

傳回已建立索引的 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
    類型:Object

    必要項。 一個絕對索引、GUID 字串或命令的完整名稱。

  • ID
    類型:Int32

    選擇項。 所指定命令集中的命令 ID。

傳回值

類型:EnvDTE.Command
Command 物件。

備註

如果 index 是絕對索引 (Long), 唯有從 1 到 n 逐一查看命令才有意義。 您不能儲存命令的絕對索引,並在稍後用來存取該命令。

如果 index 是 GUID 字串,那麼它是表示一個命令集,您必須提供 ID 引數識別命令集中的命令。

如果您提供 ID 引數,而且第一個引數是字串,則 index 引數必須是可以識別命令集的 GUID 字串。 如果 index 是字串而且沒有 ID 引數,則 index 必須是命令的完整名稱。 如果 index 是長整數,則 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 安全性

請參閱

參考

Commands 介面

EnvDTE 命名空間