I've dynamically added 20 pictureboxes to a panel and would like to see the panel scroll when I use the mouse wheel. To implement this I have tried to set the autoscroll to true on the panel control. Here is the code. For i As Integer = 1 To 20:
Dim b As New PictureBox()
b.Image = Nothing
b.BorderStyle = BorderStyle.FixedSingle
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
I did the same thing with button control and it works just fine. 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
It works for "button" control, but not for the "picturebox" or "label" controls? How can I implementthe scrolling affect using 'mousewheel'?