How to set scrollbar in windows form

I have winform in .net and I place too many controls and set the height and width of the form. But when I compile the form and reduce the size of the form, my controls are not visible. When I increase the size of the form, the controls are visible in their places.

I want the scroll bar to appear when I reduce the size of the form, and the scroll bar to disappear when we increase the size of the form.

+3
source share
6 answers

You need to use the Panel control as a container for your child controls and set the "AutoScroll" property to true.

+6
source

Set true to the AutoScroll form property.

+3
source

You can use Panel, TabControl or SplitContainer as a container and put all your tools in it. Set the panel's AutoScroll property to true to get the scroll bar on the form. Connect the control panel to fill so that it appears on the entire form.

Thanks.

0
source

Write this code in your LOAD EVENT form, and you will get your scrollbar as if I were writing it here in your form upload event.

 private void Form1_Load(object sender, EventArgs e) { Panel my_panel = new Panel(); VScrollBar vScroller = new VScrollBar(); vScroller.Dock = DockStyle.Right; vScroller.Width = 30; vScroller.Height = 200; vScroller.Name = "VScrollBar1"; my_panel.Controls.Add(vScroller); } 
0
source

Add all the controls for your window shape to the panel, write the following code in the form of the window "Load Event" and set the auto-scroll property of your window to true.

  private void Form1_Load(object sender, EventArgs e) { Panel my_panel = new Panel(); VScrollBar vScroller = new VScrollBar(); vScroller.Dock = DockStyle.Right; vScroller.Width = 30; vScroller.Height = 200; vScroller.Name = "VScrollBar1"; my_panel.Controls.Add(vScroller); } 
0
source

It should be remembered that

Set true for the AutoScroll property of the form.

starts when forms have controls to the end of the height. If the end of the forms does not contain any control and there is only a space on it, this AutoScroll property does not work.

0
source

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


All Articles