private void InitializeBlocks() { int blockCount = 1; PuzzleBlock block; for (int row = 1; row < 5; row++) { for (int col = 1; col < 5; col++) { block = new PuzzleBlock() { Top = row * 84, Left = col * 84, Text = blockCount.ToString(), Name = "Block" + blockCount.ToString() }; //block.Click += new EventHandler(Block_Click); block.Click += Block_Click; initialLocations.Add(block.Location); if (blockCount == 16) { block.Name = "EmptyBlock"; block.Text = string.Empty; block.BackColor = Color.DarkSlateBlue; block.FlatStyle = FlatStyle.Flat; block.FlatAppearance.BorderSize = 0; } blockCount++; this.Controls.Add(block); } } }
private void InitializeBlocks() { int blockCount = 1; PuzzleBlock block; for (int row = 1; row < 5; row++) { for (int col = 1; col < 5; col++) { block = new PuzzleBlock(); block.Top = row * 100; block.Left = col * 100; block.Text = blockCount.ToString(); if (blockCount == 16) { block.Text = string.Empty; block.BackColor = Color.CornflowerBlue; block.FlatStyle = FlatStyle.Flat; block.FlatAppearance.BorderSize = 0; } blockCount++; this.Controls.Add(block); } } }