.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Windows Application >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Use of Timer, TrackBar and ProgressBar Controls

Posted By:Prasanti Prusty       Posted Date: February 28, 2010    Points: 25    Category: Windows Application    URL: http://www.dotnetspark.com  

Use of Timer, TrackBar and ProgressBar Controls
 

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 :

  1. 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.
  2. Maximum : Gets or sets the upper limit of the range this System.Windows.Forms.TrackBar is working with.
  3. Minimum : Gets or sets the lower limit of the range this System.Windows.Forms.TrackBar is working with.
  4. Orientation : Gets or sets a value indicating the horizontal or vertical orientation of the track bar.
  5. Scroll : Occurs when either a mouse or keyboard action moves the scroll box.
  6. 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.
  7. TickFrequency : Gets or sets a value that specifies the delta between ticks drawn on the control.
  8. TickStyle : Gets or sets a value indicating how to display the tick marks on the track bar.
  9. Value : Gets or sets a numeric value that represents the current position of the scroll box on the track bar.
  10. 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 :

  1. Maximum : Gets or sets the maximum value of the range of the control.
  2. Minimum : Gets or sets the minimum value of the range of the control.
  3. 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

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend