using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace IMCS.Componen { public partial class Uctrl_KuWei: UserControl { public Uctrl_KuWei() { InitializeComponent(); this.Load += UserControl1_Load; } public int BaseTag { get; set; } = 0; private void UserControl1_Load(object sender, EventArgs e) { int i = 0; for (int y = 0; y < 5; y++) { for (int x = 0; x < 3; x++) { i++; // this.tableLayoutPanel1.GetControlFromPosition Label lb = this.tableLayoutPanel1.GetControlFromPosition(y, x) as Label; if (lb != null) { lb.Text = (BaseTag + i).ToString(); lb.Tag = (BaseTag + i).ToString(); lb.AutoSize = false; lb.Width = 68; lb.Height = 60; lb.BackColor = System.Drawing.Color.AliceBlue; lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; } } } } } }