Solved

VB.net Menu not appearing where mouse is

Posted on 2014-10-12
3
120 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:murbro
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:murbro
ID: 40375759
Thanks very much
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 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