2

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 is supposed to look (designed at 1920x1080)

How it looks on 1600x900:

enter image description here

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?

STHOH
  • 261
  • 1
  • 12
  • 2
    Yes, you can get better scalability with `TableLayoutPanel`. However, I would choose `WPF` with `Grid`. – L_J Jan 04 '20 at 21:50
  • Any idea, as to why the width of the taskpane does not scale. I don´t assume TableLayoutPanel would change that? – STHOH Jan 04 '20 at 22:01
  • *...nice form!* – ashleedawg Jan 05 '20 at 03:11
  • Why `AutoScaleMode` is set to `Font`? Do you have `AutoScaleDimensions` set as well? Are you running OS with a custom scale factor? – RussKie Jan 07 '20 at 00:13
  • I have realized myself that scaling to font is not the right way to do it. So now I have set it to DPI. With AutoScaleDimensions set to 96 as I now have included in the question. – STHOH Jan 07 '20 at 07:32

0 Answers0