Solved

VB.net Menu not appearing where mouse is

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now