Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scroll bar in a frame

Status
Not open for further replies.

nicklad

Programmer
May 19, 2002
29
AU
how do i add a verticle scroll bar to a frame?
thanks
 
Hi..
As far as frame is concerned, it does not have scroll bar attached
 
there must be away u can add a vscrollbar thou?
like it just cant NOT be able to be done
or am i way off?
 
If you are trying to do what I think you are, you will need to use a frame inside a frame and place the scroll bar within the outer frame and use the scroll bar to adjust the inner frames top property. This will allow you to move the inner frame up and down with in the outer frame. If you choose to battle wits with the witless be prepared to lose.
[machinegun][ducky]
 
foada.
u wouldnt be able to include some example code for what u suggested in ur message above - im a bit of a beginner so need a helping hand from someone who knows [wink]
thank u!
[thumbsup2]
 
This approach is thru the use of two frames, and the standard scroll bar control. Specific values for Height and Width may vary depending on your requirements are.

1. Create a frame (fraVisible) that is the viewable area on the screen. Be sure to increase the width of this frame to allow for the scroll bar. For this example, I have the following property settings:

Height = 5100
Left = 750
Top = 3600
Width = 12600

2. Add the standard scroll bar to the the fraVisible frame, and place is at the far right hand side of the Visible frame. Set the height of the scroll bar so that it uses the entire visible height space, keeping both the top and bottom scroll buttons visible. I have the following property settings

Height = 5115
Left = 12270
Top = 0
Width = 315

Also set the following scroll bar properties

Max = 100
Min = 0

I also set the following two properties, although you may adjust these to match your desired behavior

LargeChange = 20
SmallChange = 4

Remember, the scroll bar has been placed in the fraVisible Frame.

3. Create a second frame (fraScroll), on the fraVisible frame, but set the height of the second frame to be large enough to hold all of your controls, and then place all of your controls on this frame. In this example, I have the following properties set.

Height = 19740
Top = 0
Left = 0
Width = 12270

Again, this frame is placed on the fraVisible frame

4. Add the following event handler to your code

Private Sub scrBar_Change()

fraScroll.Top = -(scrBar.Value / 100) * (fraScroll.Height - fraVisible.Height)

End Sub


Note: In order to make design adjustments to the controls on the fraScroll frame, you will have to manually position the frame during design. Change the top property to some negative number, and you will be able during design to see those portions not initially visible. Be sure to set the top property back to 0 when design is complete, or in the Form_Load event, add fraScroll.Top = 0.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top