-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
53 lines (48 loc) · 1.32 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Drawing;
using System.Windows.Forms;
namespace RecapDemo1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GeneratedButton();
}
private void GeneratedButton()
{
Button[,] buttons = new Button[8, 8];
int top = 0;
int left = 0;
for (int i = 0; i < buttons.GetUpperBound(0); i++)
{
for (int j = 0; j < buttons.GetUpperBound(1); j++)
{
buttons[i, j] = new Button
{
Width = 50,
Height = 50,
Top = top,
Left = left,
};
left += 50;
if ((i + j) % 2 == 0)
{
buttons[i, j].BackColor = Color.Black;
}
else
{
buttons[i, j].BackColor = Color.White;
}
this.Controls.Add(buttons[i, j]);
}
top += 50;
left = 0;
}
}
}
}