close
namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
        int x;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {


            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int[] myarray = {  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16};
            for (int j = 1; j < 5; j++)
            {
                for (int i = 1; i < 5; i++)
                {
                    Buttons[i, j] = new Button();
                    Buttons[i, j].Location = new Point(80 + i * 50, 80 + j * 50);
                    Buttons[i, j].Size = new Size(50, 50);
                    x = myarray[(i - 1) * 4 + j - 1];
                    Buttons[i, j].Text = x.ToString();
                    this.Controls.Add(Buttons[i, j]);
                }
            }
        }
    }
}


arrow
arrow
    全站熱搜

    jimin01013 發表在 痞客邦 留言(0) 人氣()