Home > Net >  Winform automatic control center in the form and the problem of the scroll bar
Winform automatic control center in the form and the problem of the scroll bar

Time:09-18


Assuming the form of variable size number of controls, I set up the control center, all controls at the same time to set the anchor attribute to none, so that you can guarantee in the form size changes can still be centered when control,
But at the time of form drag size change, if the form has shrunk to control can't fully display, window scroll bar will not appear autoscroll (I set up the window to true), why is this excuse me? How to ensure that the form is very small, the scroll bar automatically appear?

At the same time, I had a test, if you want to scroll up and down automatically appear, you must set the anchor top (can't set the bottom), if you want to automatically appear around the scroll bar, you must set the anchor lef (not set right),


If you want to make the control form in size change automatically center, and automatically appear scroll bar, we generally is how to solve this problem?

CodePudding user response:

refer to the original poster bull his father replies:
... If the form has shrunk to control couldn't fully display,...


Control WinForm no minimum size, for you to do the scroll bar, much more code maintenance,
Form. MinimumSize =...

CodePudding user response:

You put behind a fixed size and position of the panel, the window is smaller than the panel will have a scroll bar
But the smallest inside of the window size is the size of the panel, you again the small window size, location button will not follow

CodePudding user response:

Put a 2 row 1 column TableLayoutPanel, Dock property is set to the Fill, set up automatic rolling, setting AutoScrollMinSize value at the same time, the value you can adjust according to the actual effect,
Put two components in the 2 rows and set the Dock for the Fill, at the same time set the Margin to adjust size
This should be

CodePudding user response:

refer to the second floor wangyx92528 response:
you put behind a fixed size and position of the panel, the window is less than the panel will have a scroll bar
But the smallest inside of the window size is the size of the panel, you again the small window size, button location will not follow changed


This method can't make the form greaten, button automatically centered within the form

CodePudding user response:

reference mf1983 reply: 3/f
put a 2 row 1 column TableLayoutPanel, Dock property is set to the Fill, set up automatic rolling, setting AutoScrollMinSize value at the same time, the value you can adjust according to the actual effect,
Put two components in the 2 rows and set the Dock for the Fill, at the same time set the Margin to adjust size
This should go


Change form test, size, and the button also changes with the size, and my initial idea is slightly different (control size remains the same, only change location)

But the result is right also, it is worth reference

Thank you ~ ~ ~ ~

CodePudding user response:

reference 1st floor github_36000833 response:
Quote: refer to the original poster bull his father replies:

. If the form has shrunk to control couldn't fully display,...


Control WinForm no minimum size, for you to do the scroll bar, much more code maintenance,
Form. MinimumSize =...


Thank you the elder brothers, drag minimal size limit, also can avoid the problem
  •  Tags:  
  • C#
  • Related