close

未命名  

 

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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
Button[,] Buttons = new Button[4, 4];
public Form1()
{
InitializeComponent();
}
Random rnd = new Random();
protected int GetRandomInt(int min, int max)
{
return rnd.Next(min, max);
}
private void Form1_Load(object sender, EventArgs e)
{

for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{

int width, height;
width = this.Size.Width;
height = this.Size.Height;
Buttons[i, j] = new Button();
Buttons[i, j].Location = new Point(i * 50, j * 50);


width = 50;
height = 50;
Buttons[i, j].Size = new Size(width, height);
Buttons[i, j].Text = GetRandomInt(1, 16).ToString();
this.Controls.Add(Buttons[i, j]);

}
}

}
}
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 open7412 的頭像
    open7412

    陳昱穎

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