I am creating an add-in for Excel that features a taskpane that is created at runtime (winforms). The taskpane is fitted with a scrollable panel, which again is fitted with labels, textboxes, groupboxes and buttons.
Everything looks great when used on a screen with the resulution at which I designed it. If I change the resolution however, there is some issues with scaling (see the two images).
How it is supposed to look (designed at 1920x1080):
How it looks on 1600x900:
Three main problems occur. First of all, the taskpane becomes too wide. Secondly, buttons aren't scaled (can't be seen from image) and thirdly, the distance between the controls are wrong.
The AutoScaleMode
of the taskpane is set to DPI
, while the AutoScaleDimensions
is set to System.Drawing.SizeF(96F, 96F)
. This makes the textbox controls and labels resize. But why does the width of the taskpane not scale down?
And what would be the best solution for making the buttons and the space between the controls scale? Do I have to but everything inside a TableLayoutPanel
?