Best WinForms user control layout with static and dynamic content?

I have a user control that has: a) a panel of buttons at the top (it should always be visible) b) a panel with controls that are dynamically added and changed at runtime. There can be many controls, so the panel must be scrollable.

This user control will be placed on the form with the following requirements: a) The original size of the form will try to fit the maximum portion of the dynamic content. b) When changing the size of the form, the control should be accordingly changed.

I played with various mounts, docking and auto-calibration, and I don’t quite understand how it works. Sometimes it scrolls, sometimes it is something else.

What combination of binding, docking and auto-size of panels, user control, form should work best to achieve the desired result?

+3
source share
3 answers

I managed to fulfill the requirements. Here is my solution:

The dynamic panel is attached to the top and bottom of the control. It is not AutoSize, it manually changes its MaximumSize and PreferredSize after changing the contents.

A form contains a form using:

        cntrl.AutoSize = true;
        cntrl.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
        cntrl.Dock = System.Windows.Forms.DockStyle.Fill;

, Height .

+2

. . , flowlayout .

+1

Without knowing the specifics of your problem, I find several fillable dock containers with one fixed panel and / or fixed slider, as a rule, it creates really convenient resizing. You can also collapse panels effectively.

0
source

Source: https://habr.com/ru/post/1702578/


All Articles