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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
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(); //生成4*4按鈕
buttons[i, j].Location = new Point(i * 50, j * 50); //按紐位置為(i*50,j*50)
buttons[i, j].Size = new Size(50, 50); //按鈕大小為50*50
this.Controls.Add(buttons[i, j]);
}
}
}
}
}
沒有留言:
張貼留言