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

cmdolcetAsked:
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:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.mouseposition(v=vs.110).aspx
which shows you where the mouse is on a control.  At a guess you are wanting that.
0
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.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Then something like this:
SearchContextMenu.Show(Me.GridSpread, Me.PointToClient(System.Windows.Forms.Control.MousePosition))
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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.
0
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))
0

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?
0
AndyAinscowFreelance programmer / ConsultantCommented:
because the ByVal e As System.Windows.Forms.MouseEventArgs gives the mouse location in client co-ordinates
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.