Scroll through data entries
Ron McCarthy
Reader Ron McCarthy gives us a nifty tip on how to see data entries when there are more of them than will fit on your tiny screen.
Have you ever needed to scroll through a large number of data entry elements only to find that the screen isn't big enough to show them all, especially in 800 X 600 resolution. Well here's the answer: "Scrolling Frames."
To see how it works:
- Create a form that does not display fully when maximized.
- Add a standard frame. Make the frames height bigger than the forms height.
- In the frame place as many textboxes as needed to fill the frame from top to bottom. Note: Make them a control array so as not to exceed the 255 controls per form limit.
- Add a FlatScrollBar to the form just to the right of the frame.
- Set the following properties:
- Appearance = 0 - fsb3D
Orientation = 0 - cc2OrientationVertical
LargeChange = 500
SmallChange = 100
When you run the application and the form is bigger than what can be displayed on the screen, the scroll bar will allow you to scroll the frame up and down so the text boxes will become visible. Of course you could put any of the other VB controls in the frame as needed for your application. The Form_Resize takes care of making the scroll bar fit on the visible form and that the frame will scroll up and down properly.
Code:
Option Explicit Private Sub
Requires Free Membership to View
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial Director Form_Load()
Form_Resize
End Sub
Private Sub Form_Resize()
'So the bar doesn't fall off the bottom
FlatScrollBar1.Height = Me.Height - 400
'Sets the scrollBar.max to a negitive number
FlatScrollBar1.Max = Me.Height - (fraMain.Height + 450)
End Sub
Private Sub FlatScrollBar1_Change()
Frame1.Top = FlatScrollBar1.Value
End Sub
Private Sub FlatScrollBar1_Scroll()
Frame1.Top = FlatScrollBar1.Value
End Sub
Related Book
Beginning Visual Basic 6 Application Development
Author : Pierre Boutquin, Jason Bock, Diane Poremsky, Matthew Reynolds
Kent Sharkey, Ken Slovak, Lee Whitney
Publisher : Wrox Press
Published : Jul 2000
Summary:
Visual Basic is a versatile language ? accessible to those seeking to enter the world of programming, yet powerful enough to support the coding of complex, distributed applications. By showing you step-by-step how to design, implement, and deploy a fully functional sophisticated application based on an online banking scenario, this book will cover the conceptual and practical implications of application development. We'll cover the full range of topics that impinge on such a project; from software architecture and project planning, through analysis of business requirements and software design by UML, to the practical coding of COM components operating in a transactional environment and the creation of a database to support these activities.
This was first published in May 2001