我正在构建一个数独游戏,我想听一个数字键并将其应用于当前选择的多维数据集。 但是,由于某些原因,按键不起作用。
我的代码:
namespace SodukoApp
{
public partial class SudokuFrame : UserControl
{
// Data
private const int buttonWidth = 34;
private const int buttonHeight = 34;
private const int spaceBetweenButtons = 5;
private const int rowAmount = 9;
private const int colAmount = 9;
private List<List<Button>> buttons;
private int numOfZeroes;
private int[,] currBoard;
private bool haveSolution;
private Button pressed;
public SudokuFrame()
{
this.buttons = new List<List<Button>>();
this.numOfZeroes = 62;
InitializeComponent();
}
private void SudokuFrame_Load(object sender, EventArgs e)
{
this.difficulty.SelectedIndex = 0;
this.buildABoard();
this.generateBoardAndPrindToScreen();
}
public void SudokuFrame_KeyPress(object sender, KeyPressEventArgs e)
{
System.Console.WriteLine("somthing");
}
private void gameBoardButton_Click(object sender, EventArgs e)
{
if(this.pressed != null)
this.pressed.FlatAppearance.BorderSize = 0;
this.pressed = (Button)sender;
this.pressed.FlatAppearance.BorderSize = 1;
}
}
请参阅下面的代码: