Professional Documents
Culture Documents
Create A Standard C# Windows Forms Application
Create A Standard C# Windows Forms Application
2. For the newly created form, set the FormBorderStyle property to FixedToolWindow:
Also, set the form Text property to "Countdown Timer" or whatever you want, so you can easily identify the
form.
view source
print?
1 public int seconds; // Seconds.
2 public int minutes; // Minutes.
view source
print?
01 private void button2_Click(object sender, EventArgs e)
02 {
04 {
06 {
07 timer1.Enabled = true;
08 button1.Enabled = true;
09 button2.Enabled = false;
10 button3.Enabled = true;
11 textBox1.Enabled = false;
12 textBox2.Enabled = false;
13 textBox3.Enabled = false;
14 textBox4.Enabled = false;
15 try
16 {
17 minutes = System.Convert.ToInt32(textBox2.Text);
18 seconds = System.Convert.ToInt32(textBox3.Text);
19 hours = System.Convert.ToInt32(textBox1.Text);
20 }
22 {
23 MessageBox.Show(ex.Message);
24 }
25 }
26 else
27 {
28 MessageBox.Show("Incomplete settings!");
29 }
30 }
31 else
32 {
33 timer1.Enabled = true;
34 paused = false;
35 button2.Enabled = false;
36 button1.Enabled = true;
37 }
38 }
view source
print?
1 private void button1_Click(object sender, EventArgs e)
2 {
4 timer1.Enabled = false;
5 paused = true;
6 button1.Enabled = false;
7 button2.Enabled = true;
8 }
view source
print?
01 private void button3_Click(object sender, EventArgs e)
02 {
04 paused = false;
05 timer1.Enabled = false;
06 button1.Enabled = false;
07 button3.Enabled = false;
08 button2.Enabled = true;
09 textBox4.Clear();
10 textBox3.Clear();
11 textBox2.Clear();
12 textBox1.Clear();
13 textBox1.Enabled = true;
14 textBox4.Enabled = true;
15 textBox3.Enabled = true;
16 textBox2.Enabled = true;
17 textBox1.Enabled = true;
18 lblHr.Text = "00";
19 lblMin.Text = "00";
20 lblSec.Text = "00";
21 }
view source
print?
01 private void timer1_Tick(object sender, EventArgs e)
02 {
05 {
08 timer1.Enabled = false;
09 MessageBox.Show(textBox4.Text);
10 button1.Enabled = false;
11 button3.Enabled = false;
12 button2.Enabled = true;
13 textBox4.Clear();
14 textBox3.Clear();
15 textBox2.Clear();
16 textBox1.Enabled = true;
17 textBox4.Enabled = true;
18 textBox3.Enabled = true;
19 textBox2.Enabled = true;
20 textBox1.Enabled = true;
21 lblHr.Text = "00";
22 lblMin.Text = "00";
23 lblSec.Text = "00";
24 }
25 else
26 {
29 {
30 seconds = 59;
31 if (minutes == 0)
32 {
33 minutes = 59;
34 if (hours != 0)
35 hours -= 1;
36
37 }
38 else
39 {
40 minutes -= 1;
41 }
42 }
43 else
44 seconds -= 1;
// Display the current values of hours, minutes and
45
seconds in
47 lblHr.Text = hours.ToString();
48 lblMin.Text = minutes.ToString();
49 lblSec.Text = seconds.ToString();
50 }
51 }
2. For the newly created form, set the FormBorderStyle property to FixedToolWindow:
Also, set the form Text property to "Countdown Timer" or whatever you want, so you can easily identify the
form.
view source
print?
1 public int seconds; // Seconds.
2 public int minutes; // Minutes.
02 {
04 {
06 {
07 timer1.Enabled = true;
08 button1.Enabled = true;
09 button2.Enabled = false;
10 button3.Enabled = true;
11 textBox1.Enabled = false;
12 textBox2.Enabled = false;
13 textBox3.Enabled = false;
14 textBox4.Enabled = false;
15 try
16 {
17 minutes = System.Convert.ToInt32(textBox2.Text);
18 seconds = System.Convert.ToInt32(textBox3.Text);
19 hours = System.Convert.ToInt32(textBox1.Text);
20 }
22 {
23 MessageBox.Show(ex.Message);
24 }
25 }
26 else
27 {
28 MessageBox.Show("Incomplete settings!");
29 }
30 }
31 else
32 {
33 timer1.Enabled = true;
34 paused = false;
35 button2.Enabled = false;
36 button1.Enabled = true;
37 }
38 }
2 {
4 timer1.Enabled = false;
5 paused = true;
6 button1.Enabled = false;
7 button2.Enabled = true;
8 }
02 {
04 paused = false;
05 timer1.Enabled = false;
06 button1.Enabled = false;
07 button3.Enabled = false;
08 button2.Enabled = true;
09 textBox4.Clear();
10 textBox3.Clear();
11 textBox2.Clear();
12 textBox1.Clear();
13 textBox1.Enabled = true;
14 textBox4.Enabled = true;
15 textBox3.Enabled = true;
16 textBox2.Enabled = true;
17 textBox1.Enabled = true;
18 lblHr.Text = "00";
19 lblMin.Text = "00";
20 lblSec.Text = "00";
21 }
02 {
05 {
08 timer1.Enabled = false;
09 MessageBox.Show(textBox4.Text);
10 button1.Enabled = false;
11 button3.Enabled = false;
12 button2.Enabled = true;
13 textBox4.Clear();
14 textBox3.Clear();
15 textBox2.Clear();
16 textBox1.Enabled = true;
17 textBox4.Enabled = true;
18 textBox3.Enabled = true;
19 textBox2.Enabled = true;
20 textBox1.Enabled = true;
21 lblHr.Text = "00";
22 lblMin.Text = "00";
23 lblSec.Text = "00";
24 }
25 else
26 {
29 {
30 seconds = 59;
31 if (minutes == 0)
32 {
33 minutes = 59;
34 if (hours != 0)
35 hours -= 1;
36
37 }
38 else
39 {
40 minutes -= 1;
41 }
42 }
43 else
44 seconds -= 1;
// Display the current values of hours, minutes and
45
seconds in
47 lblHr.Text = hours.ToString();
48 lblMin.Text = minutes.ToString();
49 lblSec.Text = seconds.ToString();
50 }
51 }