Advertisement
NickAndNick

Windows Forms. Обратный отсчёт

Jul 14th, 2014
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. namespace Test {
  4.     public partial class Form1 : Form {
  5.         public Form1() {
  6.             InitializeComponent();
  7.             this.label1.Text = "10";
  8.         }
  9.         private int count;
  10.         private Timer timer = new Timer();
  11.         private void Form1_Load(object sender, EventArgs e) {
  12.             count = Convert.ToInt32(this.label1.Text);
  13.             timer.Interval = 1000;
  14.             timer.Tick += new EventHandler(Run);
  15.             timer.Start();
  16.         }
  17.         private void Run(object sender, EventArgs e) {
  18.             --count;
  19.             if (count > 0) this.label1.Text = count.ToString();
  20.             else {
  21.                 this.label1.Text = "Конец!";
  22.                 timer.Dispose();
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement