Don't show context menu if nothing is selected
<p>I like to have a context menu only show up if an item is actually selected in a listbox in a winforms c# application.</p>

<p>Currently, I am able to select an item if it is right clicked properly, and I can disable the right click menu if nothing is selected, however, I don't want the menu to even show up.</p>

<p>how can this be accomplished?</p>

<pre><code>private void genPassMenu_Opening(object sender, CancelEventArgs e)
    {
        genPassMenu.Enabled = lstPasswords.SelectedIndex &gt; 0;
        genPassMenu.Visible = lstPasswords.SelectedIndex &gt; 0;

    }
</code></pre>

<p>I tried both of those situations on their own, and it only works for enabled.<br>
Perhaps Opening isn't the correct event to choose?<br>
Tx</p>
