c# - 以编程方式将加载项按钮添加到标准工具栏

标签 c# visual-studio add-in toolbar

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

最佳答案

尝试这样的事情:

var cBar = Application.ActiveExplorer().CommandBars["Standard"];
var button = (CommandBarButton)cBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true);
button.Caption = "Test";

关于c# - 以编程方式将加载项按钮添加到标准工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12049362/

相关文章:

c# - 未找到 System.Data 程序集

C# VSTO 展望 2007 : <dll> is not a valid Office Add-in

angularjs - 获取 ItemID Office.context.mailbox.item.itemId outlook mac os 插件

c# - 拦截来自其他程序的鼠标点击

c# - 带有泛型的 Unity3D GetComponent

c# - 为什么使用 Fiddler 时 HttpWebRequest 对象的性能会提高?

c++ - 将 DllMain winapi .dll 导入 Visual Studio 项目 C++

visual-studio - 如何从 Visual Studio 2005 的“最近的项目”窗口中删除项目/解决方案

.net - 什么是 Visual Studio 2010 Shell?

C# Outlook 从收件人那里获取 CompanyName 属性