Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do this -</p> <ul> <li>Create a new VB.NET Winforms project</li> <li>Place a Panel control on the form</li> <li>Set the "AutoScroll" property of the panel to "true"</li> <li>Place the following code in the load event of the form</li> </ul> <pre><code> For i As Integer = 1 To 100 Dim b As New Button() b.Text = i.ToString() b.Size = New Size(60, 40) b.Location = New Point(0, (i * b.Height) - b.Height) b.Parent = Panel1 Panel1.Controls.Add(b) Next </code></pre> <ul> <li>Run the project.</li> </ul> <p>You should see a form with 100 buttons inside the panel control. The panel control should contain a vertical scroll bar. Using the scroll wheel inside the panel should scroll through the buttons.</p> <p>Hope this example helps.</p> <p><strong>Edit</strong></p> <blockquote> <blockquote> <p>I added a panel and a vertical scrollbar to the right of it.</p> </blockquote> </blockquote> <p>That is not the correct way to do it. You need to use the autoscroll property of the panel.</p> <p><strong>Edit - Another Example</strong></p> <ul> <li>Create a new VB.NET project</li> <li>Place two buttons on the form</li> <li>Create a new usercontrol</li> <li>Set the autoscroll property of the usercontrol to true</li> <li>Paste the following code in the form load event</li> </ul> <pre><code> Dim uc As New UserControl1 uc.Parent = Me Me.Controls.Add(uc) uc.Size = New Size(100, 100) uc.Location = New Point(0, 0) For i As Integer = 1 To 100 Dim b As New Button() b.Text = i.ToString() b.Size = New Size(60, 40) b.Location = New Point(0, (i * b.Height) - b.Height) b.Parent = uc uc.Controls.Add(b) Next </code></pre> <ul> <li>Run the program. Click the buttons (on the form). Notice, that you have to click the usercontrol to set its focus and use the scroll wheel.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload