Solved

VB.net Menu not appearing where mouse is

Posted on 2014-10-12
3
126 Views
Last Modified: 2014-10-12
I am using the following code to show a menu on right clicking a DataGridView, but the menu shows at the the top left of the DataGridView rather than where my mouse is

      If e.Button = MouseButtons.Right Then
                Me.ContextMenuStrip1.Show(Me.DataGridView1, New System.Drawing.Point(e.X, e.Y))
                Me.ContextMenuStrip1.BringToFront()
            End if
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
ktaczala earned 250 total points
ID: 40375669
Assign the contextmenustrip to the DGV in DGV properties.  There should be no need to Manually show it.
The contextmenustrip should automatically popup when DGV is right clicked. (in the correct location.
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 40375710
in which event have you placed this code? if it is in the DGV right click event, I think the X and Y are relative to the top-left coordinates of the DGV itself.

Try this:
Me.ContextMenuStrip1.Show(Me.DataGridView1, New System.Drawing.Point(DataGridView1.left+e.X, DataGridView1.top+e.Y))

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 40375759
Thanks very much
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question