HScrollBar


The HScrollBar control represents a horizontal scroll bar. The user can drag the scroll bar’s “thumb” to select a number.

The control’s Value property gets and sets its current numeric value. The Minimum and Maximum properties determine the range of values that the control can display. These are integer values, so the HScrollBar control is not ideal for letting the user select a nonintegral value (such as 1.25).

The control’s SmallChange property determines how much the control’s Value property changes when the user clicks the arrows at the scroll bar’s ends. The LargeChange property determines how much the Value changes when the user clicks on the scroll bar between the thumb and the arrows.

Strangely, the control does not let the user actually select the value given by its Maximum property. The program can select that value using code, but the largest value the user can select is Maximum – LargeChange + 1. For example, if Maximum is 100 and LargeChange is 10 (the default values), then the user can select values up to 100 – 10 + 1 = 91.

If you set the control’s TabStop property to True, then the control can hold the input focus. While the control has the focus, you can use the arrow keys to change its value by the SmallChange amount.

The control’s Scroll event fires when the user changes the control’s value interactively. The ValueChanged event occurs when the control’s value changes either because the user changed it interactively, or because the program changed it with code. The following code shows how a program can display the hbarDays control’s Value property when the user or program changes it:

  Private Sub hbarDays_ValueChanged(ByVal sender As Object, _  ByVal e As System.EventArgs) Handles hbarDays.ValueChanged     lblDays.Text = hbarDays.Value.ToString End Sub 

Note that many controls that might otherwise require scroll bars can provide their own. For example, the ListBox, TextBox, and Panel controls can display their own scroll bars when necessary, so you don’t need to add your own.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net