0

如何让在 IDE 标准菜单中找到的命令也出现在 VS2005 的右键上下文菜单中?

4

1 回答 1

0

如果对您有帮助,我会使用类似的东西:

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _application = (DTE2)application;
    if (connectMode == ext_ConnectMode.ext_cm_Startup)
    {
    // Other command bars are: "Code Window", "ASPX Code Context"
        var commandBar = _application.CommandBars["ASPX Context"];

        CommandBarButton test =
                commandBar.Controls.Add(MsoControlType.msoControlButton,
                System.Reflection.Missing.Value,
                System.Reflection.Missing.Value,
                System.Reflection.Missing.Value, true) as CommandBarButton;

            // Set the caption of the submenuitem
            test.Caption = "Edit";
            test.Enabled = true;
            test.Visible = true;
            test.Click += new _CommandBarButtonEvents_ClickEventHandler(MyEventHandler);
    }
}
于 2012-08-17T11:29:25.317 回答