Scroll Control Into View In Panel with vb.net

Good Morning! This weekend was pretty busy. In addition to my side work and work on my current projects we had meetings with people about the formation of another band, and making plans to do some work on my house this summer.

Today’s topic was asked of me and it can be a little frustrating I guess. Basically we want to scroll within a panel to a particular control within that panel and have that control come into view. Not complicated but it works. Make it a great day!


Join me on Facebook

Public Class Form1
    Public Class MyData
        Public Sub New(ByVal ctl As Control)
            Me.Ctl = ctl
        End Sub
        Public Ctl As Control
        Public Overrides Function ToString() As String
            Return Ctl.Name
        End Function
    End Class
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each ctl As Control In Panel1.Controls
            If TypeOf ctl Is GroupBox Then
                ComboBox1.Items.Add(New MyData(ctl))
            End If
        Next
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim ctl As Control = DirectCast(ComboBox1.SelectedItem, MyData).Ctl
        Panel1.ScrollControlIntoView(ctl)
    End Sub
End Class

Technorati Tags: ,,,,,,,,,,,,,,,,,,
,,

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: