问题
By default, a winforms dropdown always extends to the right from the dropdown button / menu item. However, I have a toolbox button (similiar to chrome's options button) which is on the far-right side of the window; when clicked, the default menu would always extend outside of the window.
Are there any built-in ways to make the menu drop left from the dropdown button, or do I have to set the menu's position by hand, and manually show/hide?
Edit: there are 2 situations, where such behaviour is less than optimal:
if it's not full-screen, or close to the right end, it will hang out from the app's window; and
In a multi-monitor enviornment, it drops down on the next monitor
回答1:
Take a look at this:
http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripdropdowndirection.aspx
Assuming you're using .NET and ToolStripMenuItems, there is a DropdownDirection property that you can set to one of these enums.
回答2:
IIRC, it actually checks the size of the screen (not the window) and will drop the to the left to avoid going off of the screen. Would that be good enough?
来源:https://stackoverflow.com/questions/582491/set-dropdown-direction-in-winforms