Note that there are some explanatory texts on larger screens.

plurals
  1. POhiding a button from a plugin toolbar
    text
    copied!<p>I am developping a plugin for Visual Studio in C#. The plugin has a settings page and a few buttons in a toolbar to call commands.</p> <p>The problem is that in some circonstances, I want to hide a specific button. The best I was able to do is to disable the button.</p> <p>Is it possible to dynamically change it's visibility?</p> <p>EDIT: I wrote this question from my mobile, so maybe there is not enough details...</p> <p>I create the toolbar in the .vsct file (I created the menu in the same file)</p> <pre><code>&lt;Button guid="guidProductCmdSet" id="startCommand" priority="0x0100" type="Button"&gt; &lt;Parent guid="guidProductCmdSet" id="ToolbarGroup1" /&gt; &lt;Icon guid="Icons" id="startIcon" /&gt; &lt;Strings&gt; &lt;CommandName&gt;startCommand&lt;/CommandName&gt; &lt;ButtonText&gt;Start&lt;/ButtonText&gt; &lt;/Strings&gt; &lt;/Button&gt; </code></pre> <p>When the extension initializes, I create the commands:</p> <pre><code>var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { _startCommandId = new CommandID(GuidList.guidProducyVSICmdSet, (int)pkgCmdIDList.startCommand); var startItem = new MenuCommand(StartProcess, _startCommandId); mcs.AddCommand(startItem); } </code></pre> <p>After, I am able to disable some buttons from the toolbar like this:</p> <pre><code>var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; var mc = mcs.FindCommand(commandId); if (mc != null) { mc.Enabled = false; } </code></pre> <p>I tried mc.Visible = false, but it does nothing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload