在Visual Studio中,无论窗体是否在屏幕底部,如何使菜单栏按钮的下拉按钮出现在按钮上方,而不是在按钮下方,(即,如果窗体在屏幕底部,窗口会自动将下拉按钮置于按钮上方,我想这样做,无论窗体是否在底部。)
这可能会帮助你找到正确的方向:
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
你可以从任何对象的mouseup事件中调用此子:
Private Sub button1_MouseUp(Byval Sender as Object, _
Byval e As System.Windows.Forms.MouseEventArgs) _
Handles button1.MouseUp
HandleMouseUp(button1,e)
End sub
您可以简单地更改"New Point (e.X, e.Y)"以满足您的需要。您可以通过放置控件的x和y坐标并根据需要进行操作来创建更统一的外观。这篇文章是我从哪里拉:http://www.codeproject.com/Articles/8756/Context-Menu-and-Event-Handling-in-Visual-Basic-NE.