Results 1 to 3 of 3

Thread: Scrollbar in a Regular VB Form

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Hyderabad,India
    Posts
    1

    Cool

    My user input form is about 3 times the height of a Regular Maximized VB form.So I need to Have a Scroll bar which scrolls all my controls as soon as the control gets the focus or as I click the Up/Down arrow buttons of the Scroll bar. The functionality should work with Shift+Tab keys also. I need to implement this is my project. Please help. Please consider this as a urgent case and do send me answers asap.

    Thanks,,

    Shiva Prasad
    Programmer,
    Lumley Technology India,
    Hitec City,
    Hyderabad.
    ShivPrasad

  2. #2
    Guest
    Add PictureBox and insert the listboxes (or whatever you use) in it. Then add vertical scrollbar.

    Code:
    Private Sub Form_Resize ()
        Picture1.Move 0, 0, ScaleWidth - Scroll1.Width, ScaleHeight
        For A = 0 To List1.Count - 1
            List1.Move 0, ScaleHeight * A, Picture1.ScaleWidth, ScaleHeight
        Next A
        Scroll1.Max = List1.Count - 1
    End Sub
    
    Private Sub List1_GetFocus (Index As Integer)
        Scroll1.Value = Index
    End Sub
    
    Private Sub Scroll1_Change ()
        Picture1.Top = -Scroll1.Value * ScaleHeight
    End Sub

    SORRY! I understood wrong! And now I need to make other reply so I can see what you wrote. Hate when this happens


    [Edited by MerryVIP on 11-06-2000 at 06:34 AM]

  3. #3
    Guest

    Correction

    Okay, the same without listboxes.

    Code:
    Private Sub Form_Load ()
        Scroll1.Max = (Picture1.Height - ScaleHeight) / 15
    End Sub
    
    Private Sub Form_Resize ()
        'You have to set picture1 height yourself
        Picture1.Move 0, 0, ScaleWidth - Scroll1.Width
        Scroll1.Move ScaleWidth - Scroll1.Width, 0, , ScaleHeight
    End Sub
    
    Private Sub Scroll1_Change ()
        Picture1.Top = -Scroll1.Value * 15
    End Sub
    
    Private Sub Example_GetFocus ()
        If Scroll1.Max <= Example.Top Then Scroll1.Value = Example.Top 
    End Sub
    Hope I now got it right,

    [Edited by MerryVIP on 11-06-2000 at 06:42 AM]

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