title: C# Cursor position relative to application
body: <p>I would like to have a context menu pop up, if I perform a right click somewhere on my TreeView (not the individual nodes).</p>
  
  <p>This kinda works but the menu pops up way off the click position.
  I tried it with this trick <a href="https://stackoverflow.com/questions/19164933/cursor-position-relative-to-application">HERE</a> but it doesn't work.</p>
  
  <p>Here is my code and a scrrenshot. Any ideas ?</p>
  
  <pre><code>    private void Mainform_TreeView_MouseDown(object sender, MouseEventArgs e)
      {
          contextMenuStrip1.Show(PointToClient(Cursor.Position));
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/6m279.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6m279.png" alt="enter image description here"></a></p>