ARTICLE

Working of ScrollBars in VB.NET

Posted by Dea Saddler Articles | ASP.NET using VB.NET April 11, 2011
In this article we demonstrate on what is Windows ScrollBar control,their properties and how you can use ScrollBars.
Download Files:
 
Reader Level:

A visual basic windows form Scrollbar control used to provide easy navigation through a long list of items or a large amount of information by scrolling either horizontally or vertically within an application or control. Both controls add the scrolling functionality to the controls that do not have in built scrolling such as Container control. The scroll bar control used the scroll Event to monitor the movement of the ScrollBox along the ScrollBar. Using the Scroll Event Provide access to the ScrollBar value as it is being dragged.
 
Properties of Scrollbars:-

  • Value:- The value property is an integer value corresponding to the position of the ScrollBox in the ScrollBar. 
  • LargeChange and SmallChange:- The value property changes according to the value set in the LargeChange and smallchange property. 
  • Name :- Name property represents the unique name of the scrollbar controls.

Here we are giving an example in which something strange with scrollbars. That is if you set the minimum, maximum and LargeChange propoerty to some value. In this example vertical and horizontal Scrollbars are set with minimum=1, maximum=7 and LargeChange=2. This will allow the user to select the values between 1 and 5. When you run the program you can click and drag to select values from between 1 to 5. Whenever you release the mouse, however the ScrollBar jumps to 6. If you click the scrollbars arrow or thumb areas. You can also select values from between 1 to 6.

How to do:-

  • simply open a new project 
  • Drag the HScrollBar and VScrollBar  and Label control on form. Form will looks like below

    ScrollBar1.gif
     
  • Write the below code.

       
     Private Sub HScrollBar1_Scroll() Handles _
            HScrollBar1.Scroll
            lblHbar.Text = HScrollBar1.Value
        End Sub
        Private Sub VScrollBar1_Scroll() Handles _
            VScrollBar1.Scroll
            lblVbar.Text = VScrollBar1.Value
        End
    Sub

Output:-

ScrollBar2.gif

ScrollBar3.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor