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];
int r = 0;
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);
this.Controls.Add(Buttons[i, j]);
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Random r2 = new Random();
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
r = r2.Next(0, 15);
Buttons[i, j].Text = r.ToString();
}
}
}
2015年10月30日 星期五
2015年10月2日 星期五
3顏色
程式設計工藝大師
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
{
int x, y, c = 0, d;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
d = c % 3;
if (d == 0)
{
button1.BackColor=System.Drawing.Color.FromName("Green");
}
else
{
button1.BackColor = System.Drawing.Color.FromName("White");
}
if (d == 1)
{
button2.BackColor = System.Drawing.Color.FromName("Yellow");
}
else
{
button2.BackColor = System.Drawing.Color.FromName("White");
if (d == 2)
{
button3.BackColor = System.Drawing.Color.FromName("Red");
}
else
{
button3.BackColor = System.Drawing.Color.FromName("White");
}
}
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button3_Click_1(object sender, EventArgs e)
{
}
}
}
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
{
int x, y, c = 0, d;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
d = c % 3;
if (d == 0)
{
button1.BackColor=System.Drawing.Color.FromName("Green");
}
else
{
button1.BackColor = System.Drawing.Color.FromName("White");
}
if (d == 1)
{
button2.BackColor = System.Drawing.Color.FromName("Yellow");
}
else
{
button2.BackColor = System.Drawing.Color.FromName("White");
if (d == 2)
{
button3.BackColor = System.Drawing.Color.FromName("Red");
}
else
{
button3.BackColor = System.Drawing.Color.FromName("White");
}
}
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button3_Click_1(object sender, EventArgs e)
{
}
}
}
訂閱:
文章 (Atom)