gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 16:27:37 25 4
gpt4 key购买 nike

我为 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com