Form3.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Praktika5
  11. {
  12. public partial class Form3 : Form
  13. {
  14. ToolStripLabel dateLabel;
  15. ToolStripLabel timeLabel;
  16. ToolStripLabel infoLabel;
  17. Timer timer;
  18. public Form3()
  19. {
  20. InitializeComponent();
  21. infoLabel = new ToolStripLabel();
  22. infoLabel.Text = "Текущие дата и время:";
  23. dateLabel = new ToolStripLabel();
  24. timeLabel = new ToolStripLabel();
  25. statusStrip1.Items.Add(infoLabel);
  26. statusStrip1.Items.Add(dateLabel);
  27. statusStrip1.Items.Add(timeLabel);
  28. timer = new Timer() { Interval = 1000 };
  29. timer.Tick += timer_Tick;
  30. timer.Start();
  31. }
  32. void timer_Tick(object sender, EventArgs e)
  33. {
  34. dateLabel.Text = DateTime.Now.ToLongDateString();
  35. timeLabel.Text = DateTime.Now.ToLongTimeString();
  36. }
  37. }
  38. }