Form1.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 _01_1_ProbyKontrolek
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. int n = int.Parse(tbRozmiar.Text);
  21. int[,] T = new int[n, n];
  22. for (int i = 0; i < n; i++)
  23. for (int j = 0; j < n; j++)
  24. T[i, j] = (i + 1) * (j + 1);
  25. string s = "";
  26. for (int i = 0; i < n; i++)
  27. {
  28. for (int j = 0; j < n; j++)
  29. //s = s + " " + T[i, j].ToString();
  30. s = $"{s} {T[i,j],3}";
  31. s = s + "\r\n";
  32. }
  33. label1.Text = s;
  34. textBox1.AppendText("\r\n=======================================================================================\r\n");
  35. textBox1.AppendText(s);
  36. }
  37. private void button2_Click(object sender, EventArgs e)
  38. {
  39. if (checkBox1.Checked)
  40. {
  41. textBox1.AppendText("\r\n=======================================================================================\r\n");
  42. textBox1.AppendText((string)listBox1.SelectedItem);
  43. }
  44. else
  45. {
  46. textBox1.AppendText("\r\n=======================================================================================\r\n");
  47. textBox1.AppendText(comboBox1.Text);
  48. }
  49. }
  50. private void timer1_Tick(object sender, EventArgs e)
  51. {
  52. textBox1.AppendText ($"\r\n{DateTime.Now:HH:mm:ss}");
  53. }
  54. private void button3_Click(object sender, EventArgs e)
  55. {
  56. DateTime t1 = dateTimePicker1.Value;
  57. DateTime t2 = DateTime.Now;
  58. TimeSpan w = t2 - t1;
  59. label1.Text = $"Wiek Jana Kowalskiego: {w.TotalDays/365:f1} lat";
  60. }
  61. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  62. {
  63. checkBox1.Text = listBox1.SelectedItem.ToString();
  64. }
  65. }
  66. }