Use of Timer, TrackBar and ProgressBar Controls
TrackBar :
The TrackBar Control Provides an intuitive way
to select a value from a given range by providing a scroll box and scale of value.
The User can slide the scrollbar on the scale to point to the Desired value.
Some Important Properties of TrackBar Class are :
- LargeChange : Gets or sets a value to be added to or subtracted from the System.Windows.Forms.TrackBar.Value property when the scroll box is moved a large distance.
- Maximum : Gets or sets the upper limit of the range this System.Windows.Forms.TrackBar is working with.
- Minimum : Gets or sets the lower limit of the range this System.Windows.Forms.TrackBar is working with.
- Orientation : Gets or sets a value indicating the horizontal or vertical orientation of the track bar.
- Scroll : Occurs when either a mouse or keyboard action moves the scroll box.
- SmallChange : Gets or sets the value added to or subtracted from the System.Windows.Forms.TrackBar.Value property when the scroll box is moved a small distance.
- TickFrequency : Gets or sets a value that specifies the delta between ticks drawn on the control.
- TickStyle : Gets or sets a value indicating how to display the tick marks on the track bar.
- Value : Gets or sets a numeric value that represents the current position of the scroll box on the track bar.
- Value Changed : Occurs when the System.Windows.Forms.TrackBar.Value property of a track bar changes, either by movement of the scroll box or by manipulation in code.
Progress Bar :
A Progress Bar Control is usually displayed to indicate the status of a lengthy operation, such as installing an application,copying a file, or printing a document.
Some Importannt Members of Progress bar Class are :
- Maximum : Gets or sets the maximum value of the range of the control.
- Minimum : Gets or sets the minimum value of the range of the control.
- Value : Gets or sets the current position of the progress bar.
Code Example :
Set
The Timer1.Enable Property as True.
On
the TrackBar Control, set the Maximum Property to 1000.
TickFrequency
to 100.
TickStyle
to Top,Left.
Value
to 100
Public Class frmTimernTracknProgressBar
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ProgressBar1.Value < ProgressBar1.Maximum Then
'Increase the Progress bar Indicator
ProgressBar1.Value += 5
Else
'Reset the Progress bar Indicator
ProgressBar1.Value = ProgressBar1.Minimum
End If
lblmsg.Text = "Percentage Complete : " & ProgressBar1.Value & "%"
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
Dim trkBar As TrackBar = CType(sender, TrackBar)
If trkBar.Value >= 1 Then
'Set timer value based on the Selection
Timer1.Interval = trkBar.Value
End If
End Sub
End Class