Set dropdown direction in WinForms

江枫思渺然 提交于 2020-01-05 11:07:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!