次の方法で共有


Commands.RemoveCommandBar メソッド

AddCommandBar メソッドで作成したコマンド バーを削除します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Sub RemoveCommandBar ( _
    CommandBar As Object _
)
void RemoveCommandBar(
    Object CommandBar
)
void RemoveCommandBar(
    [InAttribute] Object^ CommandBar
)
abstract RemoveCommandBar : 
        CommandBar:Object -> unit
function RemoveCommandBar(
    CommandBar : Object
)

パラメーター

  • CommandBar
    型 : Object

    必須。 削除する CommandBar オブジェクト。

解説

コマンド バーが環境に組み込まれている場合、このメソッドは失敗します。

CommandBar オブジェクトは、Microsoft Office オブジェクト モデルのメンバーです。

' Macro code.
Imports Microsoft.VisualStudio.CommandBars
Sub RemoveCommandBarExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object. Also, for this 
   ' example to work correctly, there should be an add-in available 
   ' in the Visual Studio environment.
   Dim cmds As Commands
   Dim cmdobj As Command
   Dim customin, customout As Object
   Dim cmdbarobj As CommandBar
   Dim colAddins As AddIns

   ' Set references.
   colAddins = DTE.AddIns()
   cmds = DTE.Commands
   cmdobj = cmds.Item("File.NewFile")

   ' Create a toolbar and add the File.NewFile command to it.
   cmdbarobj = cmds.AddCommandBar("Mycmdbar", _
   vsCommandBarType.vsCommandBarTypeToolbar)
   MsgBox("Commandbar name: " & cmdbarobj.Name)
   cmdobj.AddControl(cmdbarobj)
   cmds.AddNamedCommand(colAddins.Item(1), "MyCommand", _
   "Button Text", "Some tooltip", True)
   cmds.RemoveCommandBar(cmdbarobj)
End Sub

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

Commands インターフェイス

EnvDTE 名前空間