Use of Timer, TrackBar and ProgressBar Controls

Chikul
Posted by Chikul under Windows Forms category on | Views : 4818
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
Maximum
Minimum
Orientation
Scroll
SmallChange
TickFrequency
TickStyle
Value
Value Changed


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
Minimum
Value


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

Comments or Responses

Login to post response