Solved

VB.net Menu not appearing where mouse is

Posted on 2014-10-12
3
123 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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