2014年11月27日 星期四

2014/11/28


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 WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        Random num = new Random();

        private void button1_Click(object sender, EventArgs e)
        {

        }
        Button[,] buttons = new Button[4, 4];
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    buttons[i, j] = new Button();
                    buttons[i, j].Location = new Point(i * 50, j * 50);
                    this.Controls.Add(buttons[i, j]);
                    buttons[i, j].Size = new Size(50, 50);
                    buttons[i, j].Text = Convert.ToString(num.Next(1, 16));

                }
            }
        }
    }
}

沒有留言:

張貼留言