code.club

標題: 二個label陣列的格子彼此交錯排列的方法 [打印本頁]

作者: csharp    時間: 2021-7-3 09:56
標題: 二個label陣列的格子彼此交錯排列的方法
  1. Label[] table1 = new Label[30];
  2.         Label[] table2 = new Label[30];
  3.         void setTable()
  4.         {
  5.             for(int i = 0; i < 30; i++)
  6.             {
  7.                 table1[i] = new Label();
  8.                 table2[i] = new Label();
  9.                 table1[i].Size = new Size(50, 50);
  10.                 table2[i].Size = new Size(50, 50);
  11.                 table1[i].BorderStyle = BorderStyle.FixedSingle;
  12.                 table2[i].BorderStyle = BorderStyle.FixedSingle;
  13.                 table1[i].Text = "1-" + i;
  14.                 table2[i].Text = "2-" + i;
  15.                 table1[i].Location = new System.Drawing.Point(50 + i % 6 * 110, 10 + i / 6 * 55);//每個距離是55x2
  16.                 table2[i].Location = new System.Drawing.Point(105 + i % 6 * 110, 10 + i / 6 * 55);//第二個開頭要加55起
  17.                 Controls.Add(table1[i]);
  18.                 Controls.Add(table2[i]);
  19.             }
  20.         }
複製代碼





歡迎光臨 code.club (http://code.club/) Powered by Discuz! X3.2