ContextMenuStrip show problem
-
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!
-
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!
Point desiredPoint = treeView.PointToScreen(cPt); menuStrip.Show(desiredPoint); instead of your last 2 lines
SkyWalker
-
Point desiredPoint = treeView.PointToScreen(cPt); menuStrip.Show(desiredPoint); instead of your last 2 lines
SkyWalker
thanks for your help