I have a ToolStripContainer
with a MenuStrip
and a ToolStrip
inside, both at the top. They're arranged as usual on Windows with the menu bar above the toolbar. Now, Windows Forms and DPI scaling support has always been a bit iffy. While everything looks fine at 100 %, I'm currently using 110 % DPI scaling and the menu bar and toolbar switch positions in the ToolStripContainer (I'd suspect it's the same with higher scaling factors, though):
My guess as to why this happens is that the designer places both controls at specific locations, even though they are arranged by the container, and with DPI scaling the ToolStripContainer
gets locations for its children that would be consistent with placing the toolbar above the menu bar, as if someone dragged the bars around and reordered them (which is possible interactively, after all).
Short of replacing the MenuStrip
with a MainMenu
, is there a simple(ish) way of ensuring that regardless of DPI scaling the order of both remains consistent? I've got about 50 different windows to change in pretty much the same manner and would also rather avoid putting extra code into the codebehind file¹.
Things I've tried so far:
- All changes in the designer have been applied at 100 % scale.
- Change the z-order of the toolbar and menu bar in an attempt to control their order. This works with panels and docking, but doesn't apply to
ToolStripContainer
, apparently. - Docking the
MenuStrip
at the top. Doesn't work; the designer just removesDock = None
from the code and displaysTop
as the default value, but with scaling applied, it's back toDock = None
in the designer (and even without touching theForm
in the designer, the result at runtime is the same).
¹ These are demo applications for a control library and the main point here is to keep the code clean and still providing a good experience out of the box. So a designer-only solution where the code is hidden away in already-awful code that no one reads would be preferable.