Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ContextMenuStrip show problem

ContextMenuStrip show problem

Scheduled Pinned Locked Moved C#
csharpc++helpquestionlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    josip cagalj
    wrote on last edited by
    #1

    Hi to all, for start let me say I'm new to c# but I have some experience in VC++. This is one of my first app in c# and off course I bumped into a small problem. I wont to display contextmenustrip when user press right mouse button, I'm having trouble with coordinates, they are funny out of form. Of course I've tried with clienttoscreen or screentoclient but nothing changes. Here is my code

        private void treeView\_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button != MouseButtons.Right) return;
            TreeNode curNode = e.Node;
            treeView.SelectedNode = curNode;
            ContextMenuStrip menuStrip = this.cmsState;
            Point cPt = new Point(e.X, e.Y);
            PointToScreen(cPt);
            menuStrip.Show(cPt);
        }
    

    menu appears OK but on wild coordinates, where am I wrong? Thanks!

    Mircea PuiuM 1 Reply Last reply
    0
    • J josip cagalj

      Hi to all, for start let me say I'm new to c# but I have some experience in VC++. This is one of my first app in c# and off course I bumped into a small problem. I wont to display contextmenustrip when user press right mouse button, I'm having trouble with coordinates, they are funny out of form. Of course I've tried with clienttoscreen or screentoclient but nothing changes. Here is my code

          private void treeView\_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
          {
              if (e.Button != MouseButtons.Right) return;
              TreeNode curNode = e.Node;
              treeView.SelectedNode = curNode;
              ContextMenuStrip menuStrip = this.cmsState;
              Point cPt = new Point(e.X, e.Y);
              PointToScreen(cPt);
              menuStrip.Show(cPt);
          }
      

      menu appears OK but on wild coordinates, where am I wrong? Thanks!

      Mircea PuiuM Offline
      Mircea PuiuM Offline
      Mircea Puiu
      wrote on last edited by
      #2

      Point desiredPoint = treeView.PointToScreen(cPt); menuStrip.Show(desiredPoint); instead of your last 2 lines

      SkyWalker

      J 1 Reply Last reply
      0
      • Mircea PuiuM Mircea Puiu

        Point desiredPoint = treeView.PointToScreen(cPt); menuStrip.Show(desiredPoint); instead of your last 2 lines

        SkyWalker

        J Offline
        J Offline
        josip cagalj
        wrote on last edited by
        #3

        thanks for your help

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups