我为visual studio编写简单的加载项。加载项包含两个命令:
command1 = commands.AddNamedCommand2(_addInInstance, "AAAA", "AAAA", "Executes the command for MyAddin2" ,true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
command2 = commands.AddNamedCommand2(_addInInstance, "BBBB", "BBBB", "Executes the command for MyAddin2", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);
当我运行加载项时,这两个按钮位于Visual Studio的“工具”选项卡下。 我希望它们出现在标准工具栏中。手动,我可以通过工具 - >自定义 - >命令选项卡 - >添加命令 - >选择插件,然后选择我的两个按钮。我可以通过编程方式进行吗? 任何帮助将不胜感激。
答案 0 :(得分:0)
尝试这样的事情:
var cBar = Application.ActiveExplorer().CommandBars["Standard"];
var button = (CommandBarButton)cBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true);
button.Caption = "Test";