JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Setting Up Scroll Bar Clicks (Large Changes)

The Testing Department is calling again. The scroll bars you've added to your program, SuperDuperTextPro, look terrific. But why doesn't anything happen when the user clicks the scroll bar itself, in the area between the scroll box and an arrow button? You ask: Should something happen? They say: Yes.

When the user clicks the scroll bar itself, not the scroll box and not an arrow button, the scroll box should move in that direction by the amount set by the scroll bar's LargeChange property (see also the next topic, which deals with the SmallChange property). For example, if you've set the scroll bar's range to be 1-100, a reasonable LargeChange setting would be 10. You can set the LargeChange property at design time, or at run time.

Here's an example where we set the LargeChange property for two scroll bars, a horizontal one and a vertical one:

Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    HScrollBar1.Minimum = 0
    HScrollBar1.Maximum = 100
    HScrollBar1.LargeChange = 10
End Sub

Now, when the user clicks the scroll bar between the scroll box and arrow buttons, the scroll bar's value will increase or decrease by 10.

Note that on some occasions, you should change the LargeChange property while a program is running. For example, if you let the user scroll through a document with this property, setting it to 1, and the user loads in a 30,000-line document, it might be wise to change the value of this property.


This is one of those values that you should test yourself, because it's part of your program's feel. I know of a graphics program that scrolls exactly one pixelat a time when you click the arrow buttons in the scroll bars next to an image. Such a thing is annoying and gives users the impression that your program is unresponsive and hard to use.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor