-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFig-13.42 - ClockUserControl.cs
More file actions
52 lines (41 loc) · 1.24 KB
/
Copy pathFig-13.42 - ClockUserControl.cs
File metadata and controls
52 lines (41 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Fig. 13.42: ClockUserControl.cs
// Controle definido pelo usuário com um temporizador e um rótulo.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
public class ClockUserControl : UserControl
{
private Timer clockTimer;
private Label displayLabel;
private Container? components = null;
private void InitializeComponent()
{
this.clockTimer = new Timer();
this.displayLabel = new Label();
// clockTimer.
this.clockTimer.Enabled = true;
this.clockTimer.Interval = 100;
this.clockTimer.Tick += new EventHandler(clockTimer_Tick);
// displayLabel.
this.displayLabel.Name = "displayLabel";
this.displayLabel.Text = "";
this.displayLabel.AutoSize = true;
this.displayLabel.Location = new Point(10, 10);
// ClockUserControl.
this.Controls.Add(this.displayLabel);
this.Name = "ClockUserControl";
this.Text = "ClockUserControl";
this.AutoSize = true;
}
private void clockTimer_Tick(object? sender, EventArgs e)
{ displayLabel.Text = DateTime.Now.ToLongTimeString(); }
public ClockUserControl()
{ InitializeComponent(); }
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{ components.Dispose(); }
base.Dispose(disposing);
}
}