# GrapeCity.ActiveReports.Viewer.Win.Viewer.SetShortcutCommandState

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetShortcutCommandState_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.SetShortcutCommandState*">SetShortcutCommandState Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetShortcutCommandState_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.SetShortcutCommandState*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetShortcutCommandState_GrapeCity_ActiveReports_Viewer_Win_ViewerCommand_System_Boolean_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.SetShortcutCommandState(GrapeCity.ActiveReports.Viewer.Win.ViewerCommand,System.Boolean)">SetShortcutCommandState(ViewerCommand, bool)</h4>
<div class="markdown level1 summary"><p>Sets the enabled or disabled state of a specified viewer command.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void SetShortcutCommandState(ViewerCommand viewerCommand, bool state)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Viewer.Win.ViewerCommand.html">ViewerCommand</a></td>
      <td><span class="parametername">viewerCommand</span></td>
      <td><p>The <a class="xref" href="GrapeCity.ActiveReports.Viewer.Win.ViewerCommand.html">ViewerCommand</a> for which to set the enabled state.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">state</span></td>
      <td><p>If <code>true</code>, the command is enabled; otherwise, it is disabled.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetShortcutCommandState_GrapeCity_ActiveReports_Viewer_Win_ViewerCommand_System_Boolean__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method allows for the dynamic enabling or disabling of commands within the viewer,
which can be useful for adjusting the available actions based on the current state or
selection within the viewer. For example, disabling a 'Print' command when no document is loaded.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetShortcutCommandState_GrapeCity_ActiveReports_Viewer_Win_ViewerCommand_System_Boolean__examples">Examples</h5>
<pre><code class="lang-csharp">// Assuming 'viewer' is an instance of Viewer.
// Enabling the Print command.
viewer.SetShortcutCommandState(ViewerCommand.Print, true);
// Disabling the ZoomIn command.
viewer.SetShortcutCommandState(ViewerCommand.ZoomIn, false);</code></pre>

<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Condition</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></td>
      <td><p>Thrown if the toolbar shortcut storage has not been initialized.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
