Question

In Visual Studio, how do you make a drop-down for a menu-strip button appear ABOVE the button, instead of below it, regardless of whether or not the form is on the bottom of the screen (I.e. windows automatically places the drop-down above the button if the form is on the bottom of the screen, I want to do this regardless of whether or not it is on the bottom.)

Was it helpful?

Solution

This may help point you in the right direction:

Private Sub HandleMouseUp(Byval Control as Object, _
      Byval e As System.Windows.Forms.MouseEventArgs)

' Checking the Mouse right Button
If e.Button = MouseButtons.Right Then
    Control.ContextMenu.Show(Control, New Point(e.X,e.Y))
End if
End sub

You can then call this sub from any object's mouseup event:

Private Sub button1_MouseUp(Byval Sender as Object, _
   Byval e As System.Windows.Forms.MouseEventArgs) _
   Handles button1.MouseUp
HandleMouseUp(button1,e)
End sub

You would then simply change the "New Point (e.X, e.Y)" to suit your needs. You could create a more uniform look by placing the x and y coordinates of your control and manipulating as needed. This article is where I am pulling from: http://www.codeproject.com/Articles/8756/Context-Menu-and-Event-Handling-in-Visual-Basic-NE.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top