Results 1 to 8 of 8

Thread: ScrollBars, how do I use them

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    26

    Question ScrollBars, how do I use them

    I have a picture box, filled with a list of labels. I'm currently using two buttons to scroll the list up and down. I want to use the scrollbars instead, but dont know where to start.

    Any tips?

  2. #2
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    Code:
    Private Sub Form_Load()
     VScroll1.Min = 0
     VScroll1.Max = 50
    End Sub
    
    Private Sub VScroll1_Change()
     Label1.Top = VScroll1.Value
    End Sub
    
    Private Sub VScroll1_Scroll()
     Call VScroll1_Change
    End Sub
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  3. #3
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    I really didn't understand what you meant by Labels for a picture box. But anyway trying an array and use Value property of Scroll Bar for showing the element at a particular index

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    I think what you are after is to display labels in a picture box and to have the whole display scroll as you click the scroll bars. This is achieved by having a picture box within a picture box and scrolling accordingly. I have given a very basic example but you can experiment and add features as required. Pls note that you should also consider whether scrolling data is really necessary in your design because it sometimes confuses users.

    Example... On Form1 Add a Picture box (Picture1)... INSIDE this picture box add a Vertical Scroll bar (VScroll1) on the right side of the picture. Again INSIDE Picture 1 add another Picture box (Picture2)... This now makes Picture1 the container for Picture 2 and VScroll1. Now add this code

    VB Code:
    1. Private Sub Form_Load()
    2.     Picture1.Height = 3000
    3.     Picture2.Height = 5000
    4.     VScroll1.Height = 3000
    5.  
    6.     VScroll1.Min = 0
    7.     VScroll1.Max = (Picture2.Height - Picture1.Height) / 100
    8. End Sub
    9.  
    10. Private Sub VScroll1_Change()
    11.     Picture2.Top = -VScroll1.Value * 100
    12. End Sub

    As I said, this is VERY basic and you can adjust as required.
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    26
    Thanks all

  6. #6
    New Member
    Join Date
    Sep 2001
    Posts
    4

    Stuart

    Good , to-the-point explanation Stuart.



    TO_raptor

  7. #7
    DaoK
    Guest
    TO_raptor what do you want to do maybe we can help you more and for basic question you can go to the microsoft help there : Microsoft Free Help

  8. #8
    New Member
    Join Date
    Sep 2001
    Posts
    4

    Smile last post rephrase

    Hi there,

    I was complimenting stuart for his explanation. thats all.

    I ll be more descriptive when i have a question.

    thanks for your hyperactive concern DAOK

    good luck!
    Developer
    Canada

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