VB Context menu and control set

I am trying to set me context menu right click location to open whenever the user clicks on my control (Me.GridSpread). It always seem to open on right click of the context control itself on the upper menu button area.

Private Sub frmSearch_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Right Then
            SearchContextMenu.Show(Me.GridSpread, New System.Drawing.Point(0, 200))
        End If
    End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
See: https://msdn.microsoft.com/en-us/library/s00cc2f3(v=vs.110).aspx

With this line of code
SearchContextMenu.Show(Me.GridSpread, New System.Drawing.Point(0, 200))
you display the context menu at the point 0,200 - ALWAYS.  In other words it is working as you have coded it to work.

You might also want to look at:
which shows you where the mouse is on a control.  At a guess you are wanting that.
cmdolcetAuthor Commented:
Yes I agree displaying it works fine, however to activate that display on the event of the right mouse click is not on the gridSpread but where the context menu is place on the screen in the IDE.
AndyAinscowFreelance programmer / ConsultantCommented:
Then something like this:
SearchContextMenu.Show(Me.GridSpread, Me.PointToClient(System.Windows.Forms.Control.MousePosition))
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

cmdolcetAuthor Commented:
OK great that shows up on the grid... However I want to be able to initiate it when when I right click on the gird, that is what I ultimately want. Right now it is initiated on the top of the form where the actual control sits.
AndyAinscowFreelance programmer / ConsultantCommented:
This dropped off the radar.
Looks like the mouse position is already in client coordinates so this should be fine
ContextMenuStrip1.Show(Me, New Point(e.X, e.Y))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cmdolcetAuthor Commented:
Andy would the "Me, New Point(e.X, e.Y)" as new point help solve this issue as to where the Right click is made?
AndyAinscowFreelance programmer / ConsultantCommented:
because the ByVal e As System.Windows.Forms.MouseEventArgs gives the mouse location in client co-ordinates
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.