如何让命令出现在VS2005的右键菜单中?

时间:2012-08-17 07:53:26

标签: visual-studio-2005 contextmenu right-click

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

1 个答案:

答案 0 :(得分: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);
    }
}