How to display the ContextMenuStrip when item is selected in a list box c# .net
<p>I'm trying select an item from list box when is right clicked and show the ContextMenuStrip to display my options available, but when I click everywhere in the control (list box) is showing the ContextMenuStrip.</p>

<p>This is what I have in code:</p>

<pre><code>private void lbSMTPEmails_MouseDown(object sender, MouseEventArgs e)
{       
       int SelectedIndex = lbSMTPEmails.IndexFromPoint(e.X, e.Y);

       if (SelectedIndex == -1)
            lbSMTPEmails.ContextMenuStrip.Hide();            
        else
        {
            lbSMTPEmails.SelectedIndex = SelectedIndex;
            lbSMTPEmails.ContextMenuStrip.Show();
        }
}
</code></pre>

<p>do you have any idea how to solve this?</p>