際際滷

際際滷Share a Scribd company logo
Prepared by: Group 5
Timer control and Tool Strip C#
Properties Description
Enabled
Property used to Get or set
whether the timer is running.
Interval
Property used to set or get the
time in millisecond between the
timer clicks.
Methods
Events Description
Start Method used to start timer.
Stop Method used to stop timer.
Event
Events Description
Tick
Triggered when the time interval
has elapsed.
Timer control and Tool Strip C#
After that we alter the
properties of the control
and set the .Interval
property to 1000ms:
Then we take a look at the event
list (by pressing the yellow flash
above the properties) and we can
see that there is only one event,
Tick. Double click on it to open it
up for editing:
private void timTimer_Tick(object sender, EventArgs e)
{
txtMain.AppendText(string.Format("Time: {0}n
", DateTime.Now.ToLongTimeString()));
}
private void btnStart_Click(object sender, EventArgs e)
{
timTimer.Enabled = true;
}
private void btnStop_Click(object sender, EventArgs e)
{
timTimer.Enabled = false;
}
Timer control and Tool Strip C#
To add a toolbar
to the top of your
form, expand the
Toolbox and
locate the
ToolStrip control.
Timer control and Tool Strip C#
Timer control and Tool Strip C#
Timer control and Tool Strip C#
Timer control and Tool Strip C#
Timer control and Tool Strip C#

More Related Content

Timer control and Tool Strip C#

  • 3. Properties Description Enabled Property used to Get or set whether the timer is running. Interval Property used to set or get the time in millisecond between the timer clicks. Methods Events Description Start Method used to start timer. Stop Method used to stop timer. Event Events Description Tick Triggered when the time interval has elapsed.
  • 5. After that we alter the properties of the control and set the .Interval property to 1000ms: Then we take a look at the event list (by pressing the yellow flash above the properties) and we can see that there is only one event, Tick. Double click on it to open it up for editing:
  • 6. private void timTimer_Tick(object sender, EventArgs e) { txtMain.AppendText(string.Format("Time: {0}n ", DateTime.Now.ToLongTimeString())); }
  • 7. private void btnStart_Click(object sender, EventArgs e) { timTimer.Enabled = true; } private void btnStop_Click(object sender, EventArgs e) { timTimer.Enabled = false; }
  • 9. To add a toolbar to the top of your form, expand the Toolbox and locate the ToolStrip control.