I used Winform in C# Visual Studio. At first I had an OnKeyDown and it worked well. After this i added a button to the form. I dragged the button from the toolbox and doubleclicked on it. Then it generated me the public void function.
The Button is also working fine now, but i cant use the KeyEvent anymore. What do i have to change?
protected override void OnKeyDown(KeyEventArgs e)
{
Debug.WriteLine("hello Keyevent");
}
private void button1_Click_1(object sender, EventArgs e)
{
Debug.WriteLine("hello button");
}
Paint-Method:
protected override void OnPaint(PaintEventArgs e)
{
grafik = e.Graphics;
using (Font font1 = new Font("Arial", 20, FontStyle.Regular, GraphicsUnit.Point))
{
StringFormat TextFormat = new StringFormat()
{
Alignment = StringAlignment.Center,
};
Rectangle myRectangle = new Rectangle();
for (int i = 0; i < maze.GetLength(0); i++)
{
for (int j = 0; j < maze.GetLength(1); j++)
{
string sign = char.ToString(Labyrinth[i, j]);
myRectangle.Location = new Point(i * 30, j * 30);
myRectangle.Size = new Size(10, 10);
grafik.DrawString(sign, font1, red, myRectangle, TextFormat);
}
}
}
}