Results 1 to 5 of 5

Thread: [2005] Scrollbar question

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    37

    [2005] Scrollbar question

    can anyone teach me how to control 2 scroll line so that when i control either one the another one will move together
    Attached Images Attached Images  
    Last edited by kahwai1984; Aug 17th, 2007 at 07:59 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Scrollbar question

    What type of controls are those? ListViews?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    37

    Re: [2005] Scrollbar question

    Quote Originally Posted by jmcilhinney
    What type of controls are those? ListViews?
    yes, is a listview

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    37

    Re: [2005] Scrollbar question

    no people can help?

  5. #5
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2005] Scrollbar question

    Since the ListView does not have a scroll event, put each listview into a panel and set the properties of the panels/listviews as below. This uses the panel scroll event to keep the scrollbars aligned with whichever is changed.

    Code:
    Option Strict On
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles MyBase.Load
    
            'Put the two listviews into two panels
            Panel1.Size = ListView1.Size
            Panel2.Size = ListView2.Size
            Panel1.AutoScroll = True
            Panel2.AutoScroll = True
            Panel1.AutoSize = False
            Panel2.AutoSize = False
            ListView1.Scrollable = False
            ListView2.Scrollable = False
            ListView1.Dock = DockStyle.None
            ListView2.Dock = DockStyle.None
    
            'Some test data
            ListView1.Columns.Add("Data")
            ListView2.Columns.Add("Data")
            For i As Integer = 0 To 50
                ListView1.Items.Add(i.ToString)
                ListView2.Items.Add(i.ToString)
            Next
    
        End Sub
        Private Sub Panel1_Scroll(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.ScrollEventArgs) Handles Panel1.Scroll
            If e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then
                Panel2.HorizontalScroll.Value = e.NewValue
            Else
                Panel2.VerticalScroll.Value = e.NewValue
            End If
        End Sub
        Private Sub Panel2_Scroll(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.ScrollEventArgs) Handles Panel2.Scroll
            If e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then
                Panel1.HorizontalScroll.Value = e.NewValue
            Else
                Panel1.VerticalScroll.Value = e.NewValue
            End If
        End Sub
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width