close

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{

Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

for (int j = 1; j < 5 ; j++ )
{
for (int i = 1; i < 5; i++)
{

Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);

Buttons[i, j].Location = new Point(i * 50, j * 50);
Buttons[i, j].BackColor = Color.Pink;
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}

}

private void button1_Click(object sender, EventArgs e)
{
int pro;
for (int j = 1; j < 5; j++)
{
for (int i = 1; i < 5; i++)
{
pro = i * 1;
Buttons[i, 1].Text = pro.ToString();
pro = i +4;
Buttons[i, 2].Text = pro.ToString();
pro = i +8;
Buttons[i, 3].Text = pro.ToString();
pro = i +12;
Buttons[i, 4].Text = pro.ToString();

}
}
}
}
}1233  

arrow
arrow
    全站熱搜

    <a href="http:// 發表在 痞客邦 留言(0) 人氣()