using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
System.Windows.Forms.TextBox[] TextBoxes;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TextBoxes = new System.Windows.Forms.TextBox[46];
for (int i = 1; i <= 16; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 4)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 1) * 106, 12);
else if (i > 4 && i <= 8)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 5) * 106, 40);
else if (i > 8 && i <= 12)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 9) * 106, 68);
else if (i > 12 && i <= 16)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 13) * 106, 96);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
for (int i = 17; i <= 33; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 20)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 17) * 106, 12);
else if (i > 20 && i <= 24)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 21) * 106, 40);
else if (i > 24 && i <= 28)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 25) * 106, 68);
else if (i > 28 && i <= 32)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 29) * 106, 96);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
for (int i = 34; i <= 48; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 37)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 33) * 106, 512);
else if (i > 37 && i <= 41)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 37) * 106, 540);
else if (i > 41 && i <= 45)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 41) * 106, 568);
else if (i > 45 && i <= 48)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 45) * 106, 596);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
}
}
}
沒有留言:
張貼留言