2

Visual Studio 用の簡単なアドインを作成します。アドインには次の 2 つのコマンドが含まれています。

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);

アドインを実行すると、これら 2 つのボタンが Visual Studio の [ツール] タブの下に表示されます。それらを標準のツールバーに表示したい。手動では、[ツール] -> [カスタマイズ] -> [コマンド] タブ -> [コマンドの追加] -> [アドイン] を選択してから、2 つのボタンを選択します。プログラムでそれを行うことはできますか?どんな助けでも大歓迎です。

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 に答える