Uctrl_KuWei.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 IMCS.Componen
  11. {
  12. public partial class Uctrl_KuWei: UserControl
  13. {
  14. public Uctrl_KuWei()
  15. {
  16. InitializeComponent();
  17. this.Load += UserControl1_Load;
  18. }
  19. public int BaseTag { get; set; } = 0;
  20. private void UserControl1_Load(object sender, EventArgs e)
  21. {
  22. int i = 0;
  23. for (int y = 0; y < 5; y++)
  24. {
  25. for (int x = 0; x < 3; x++)
  26. {
  27. i++;
  28. // this.tableLayoutPanel1.GetControlFromPosition
  29. Label lb = this.tableLayoutPanel1.GetControlFromPosition(y, x) as Label;
  30. if (lb != null)
  31. {
  32. lb.Text = (BaseTag + i).ToString();
  33. lb.Tag = (BaseTag + i).ToString();
  34. lb.AutoSize = false;
  35. lb.Width = 68;
  36. lb.Height = 60;
  37. lb.BackColor = System.Drawing.Color.AliceBlue;
  38. lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }