code.club
標題:
二個label陣列的格子彼此交錯排列的方法
[打印本頁]
作者:
csharp
時間:
2021-7-3 09:56
標題:
二個label陣列的格子彼此交錯排列的方法
Label[] table1 = new Label[30];
Label[] table2 = new Label[30];
void setTable()
{
for(int i = 0; i < 30; i++)
{
table1[i] = new Label();
table2[i] = new Label();
table1[i].Size = new Size(50, 50);
table2[i].Size = new Size(50, 50);
table1[i].BorderStyle = BorderStyle.FixedSingle;
table2[i].BorderStyle = BorderStyle.FixedSingle;
table1[i].Text = "1-" + i;
table2[i].Text = "2-" + i;
table1[i].Location = new System.Drawing.Point(50 + i % 6 * 110, 10 + i / 6 * 55);//每個距離是55x2
table2[i].Location = new System.Drawing.Point(105 + i % 6 * 110, 10 + i / 6 * 55);//第二個開頭要加55起
Controls.Add(table1[i]);
Controls.Add(table2[i]);
}
}
複製代碼
歡迎光臨 code.club (https://code.club/)
Powered by Discuz! X3.2