Command.ID 属性

获取用于表示此命令的命令组 GUID 内的 ID。

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

语法

声明
ReadOnly Property ID As Integer
    Get
int ID { get; }
property int ID {
    int get ();
}
abstract ID : int
function get ID () : int

属性值

类型:System.Int32
表示命令 ID 的整数。

示例

Sub IDExample(ByVal dte As DTE2)

    ' Create a new text document.
    Dim win As Window = dte.ItemOperations.NewFile()
    Dim textWin As TextWindow = CType(win.Object, TextWindow)

    ' Split the text document window.
    Dim cmd As Command = dte.Commands.Item("Window.Split")
    dte.Commands.Raise(cmd.Guid, cmd.ID, Nothing, Nothing)

    If MsgBox("Activate the top pane?", MsgBoxStyle.YesNo) = _
        MsgBoxResult.Yes Then

        ' In a split window, the top pane is always at index 2 of the 
        ' Panes collection.
        textWin.Panes.Item(2).Activate()
    Else
        textWin.Panes.Item(1).Activate()
    End If

End Sub
public void IDExample(DTE2 dte)
{
    // Create a new text document.
    Window win = dte.ItemOperations.NewFile(@"General\Text File", "", 
        Constants.vsViewKindPrimary);
    TextWindow textWin = (TextWindow)win.Object;

    // Split the text document window.
    Command cmd = dte.Commands.Item("Window.Split", -1);
    object dummy = new object();
    dte.Commands.Raise(cmd.Guid, cmd.ID, ref dummy, ref dummy);

    if (MessageBox.Show("Activate the top pane?", "", 
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        // In a split window, the top pane is always at index 2 of the 
        // Panes collection.
        textWin.Panes.Item(2).Activate();
    }
    else
    {
        textWin.Panes.Item(1).Activate();
    }
}

.NET Framework 安全性

请参见

参考

Command 接口

EnvDTE 命名空间

其他资源

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