How to make Winform scrollable in C#

2019-06-14 14:11发布

问题:

I have create (I am using Visual Studio 2012) winform that have this proprities:

  • Width: 812
  • Height: 667
  • FormBorderStyle: Fixed 3D

In right side of put vScrollBar (that have height: 599px, which is exactly the size in my fixed form). Now I whant that my form height would be heigher then 667px, and with help of scrollbar, you scroll to bottom of form. Let me put it in picture:

Now I whant to create If you scroll with scroll bar textboxs and etc. moves down, so you can see textboxes that are at the moment hidden (they are down of form).

So far I do not have any code.

Is there any tutorial that could help me. Realy thanks for help.

回答1:

You can add a FlowLayoutPanel and set the these properties to that:

 flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
 flowLayoutPanel1.WrapContents = false;
 flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
 flowLayoutPanel1.AutoScroll = true;

and you can see the scroll, you can use the Panels and design your application.


Or completely different, You can set the this.AutoSize = true; and drag one control to outer of form(big and small the size) and then, you can see the scrollBar of form.



回答2:

You can simply try this.AutoScroll = true; which will make automatic scrolling