Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4.  
  5. namespace WindowsFormsApp1
  6. {
  7.     public partial class Form1 : Form
  8.     {
  9.         List<Label> labels = new List<Label>();
  10.  
  11.         public Form1()
  12.         {
  13.             try
  14.             {
  15.                 //InitializeComponent();
  16.  
  17.                 Width = 500;
  18.  
  19.                 var flp = new FlowLayoutPanel { Parent = this, Dock = DockStyle.Fill };
  20.  
  21.                 for (int i = 0; i < 32; i++)
  22.                 {
  23.                     var label = new Label { Parent = flp, Width = 150, BorderStyle = BorderStyle.FixedSingle };
  24.                     labels.Add(label);
  25.                 }
  26.  
  27.                 var timer = new Timer();
  28.                 timer.Interval = 1000;
  29.                 timer.Tick += Timer_Tick;
  30.                 timer.Start();
  31.             }
  32.             catch (Exception ex) { MessageBox.Show(ex.Message); Environment.Exit(1); }
  33.         }
  34.  
  35.         private void Timer_Tick(object sender, EventArgs e)
  36.         {
  37.             foreach (var label in labels)
  38.             {
  39.                 label.Text = DateTime.UtcNow.ToString("o");
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement