Как скрыть button?
Категория: .NET
2011-09-08 23:00:09
code: #csharp
const int n = 4; Button[,] Num; Random Rand = new Random(); private void Randomize() { int index = 16; while (index != 0) { int Rx = Rand.Next(n); int Ry = Rand.Next(n); if (index == 16) { Num[Rx, Ry].Text = index.ToString(); Num[Rx, Ry].Hide(); index--; } else if (Num[Rx, Ry].Text == "") { Num[Rx, Ry].Text = index.ToString(); --index; } } } private void button1_Click(object sender, EventArgs e) { Randomize(); } private void Form1_Load(object sender, EventArgs e) { Num = new Button[n, n]; for (int i = 0; i < Num.GetLength(0); i++) for (int j = 0; j < Num.GetLength(1); j++) { Num[i, j] = new Button(); Num[i, j].Location = new Point(30 * i, 30 * j); Num[i, j].Size = new Size(30, 30); // Num[i, j].Click += new EventHandler(Event); Controls.Add(Num[i, j]); } }
Поделиться: