Context Menu Position

  • Thread starter Thread starter Salazaar
  • Start date Start date
S

Salazaar

Hi,

Is there a way to make a ContextMenu always appear at a particular position
only, irrespective of where on the control the mouse is clicked.By default,
it appears slightly to the right of the mouse pointer when the appropriate
control is clicked.

Specifically, I want my contextmenu to appear attached to the bottom of a
button, whenever the button is clicked.

Please help.
 
Hi

I didnt have time to make a project to test this but the following code
should work:

Dim menu As ContextMenu
Dim MyButton As Button
menu.Show(MyButton, New Point(0, 0))

So just add the Show code in the buttons click handler and it should display
in the proper position (although now that I think about it your probably
going to have to subtract the height of the menu from the point, or add the
height of the button, depending on where you want the menu to popup).

Hope it helps (and that it was correct)
/Dan
 
* "Salazaar said:
Is there a way to make a ContextMenu always appear at a particular position
only, irrespective of where on the control the mouse is clicked.By default,
it appears slightly to the right of the mouse pointer when the appropriate
control is clicked.

Specifically, I want my contextmenu to appear attached to the bottom of a
button, whenever the button is clicked.

You can show the contextmenu in the 'MouseUp' event handler by calling
its 'Show' method and passing a control + position to this method.

Please post to groups which are related to your question only!
 
Back
Top