2

我为 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 的“工具”选项卡下。我希望它们出现在标准工具栏中。手动,我可以通过工具 -> 自定义 -> 命令选项卡 -> 添加命令 -> 选择插件然后选择我的两个按钮来做到这一点。我可以以编程方式进行吗?任何帮助将不胜感激。

4

1 回答 1

0

尝试这样的事情:

var cBar = Application.ActiveExplorer().CommandBars["Standard"];
var button = (CommandBarButton)cBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true);
button.Caption = "Test";
于 2013-01-07T16:18:28.243 回答