I saw in the internet the problem, and the solution was setting the "KeyPreview" to "true". I have tried it, and it still didn't work. Why when I press one of the arrows (down, up, left or right) the lable still doesn't show off?
Updated:
Thank you for your answer Peter Vegter, but It still doesn't work.
To make this clear: regular letter
does work and makes the label show off. The thing is that the arrows (down, up, left or right)
don't work.
I think I know why - the "focus" is on the the button and not on the form.
I searched for this in the internet, and I found that I need to make the "KeyPreview" set as "true". I did it, and still it doesn't show the label when I press the arrows, only when I press letters.
If i remove the button, the arrows
do work.
What I have tried:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
label1.Visible = false;
this.KeyPreview = true;
this.KeyDown += Form1_KeyDown;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
label1.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
}
}