tags:

views:

25

answers:

1

Is it possible to use WinForms layout engine to set up a form in such a way that the height is adjusted completely automatically to fit the content, but the width would be adjustable by the user?

As an example, consider the following somewhat contrived form:

  • TLP: TableLayoutPanel, with 1 row and 2 columns.
  • label1: Label, contained in the left column. Set Text to something long, AutoSize to false, Dock to Fill.
  • button1: Button, contained in the right column. Set AutoSize to true.
  • Now set the row to "AutoSize", the first column to "100%" and the second column to "AutoSize".
  • Finally, set the whole TLP to AutoSize true, AutoSizeMode to GrowAndShrink.

At this point, the TLP could reasonably be resized horizontally, but WinForms doesn't seem to allow this.

The idea is that the form containing this TLP would grow or shrink vertically based on the width, which the user can change by resizing the window as usual.