Solved

VB.net Menu not appearing where mouse is

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create a Dropdown list with sub group 10 43
VB.net VSTO Excel Ribbon error 4 27
VB6 calling COM DLL written in Visual Studio 2003 6 56
How to call new form in VB2013? 4 31
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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