I have more or less the same problem as this guy but his post is 2 years old, so I thought I could open a new one.
In the program I use labels and as I found out mnemonics on labels trigger the enter
event of the next control in the tab order. So implemented click
and enter
methods. But here is the problem. I created a test program. The program persists out of two labels, a button and a textbox.
Second label is just to control if the enter
event is fired. When I hit ALT
the underscore appears fine but when I press the second key (for Reset
) nothing happens. Furthermore if the underscore appears and I press the ALT
key again he doesn't disappear and the button
totally ignores if ALT
is pressed or not.
I moved to an other pc with VisualStudio 2013 but got the same result. I downloaded the VisualStudio 2017, tried to create new program => does not work either.
English is not the language I know the best, so I'm glad if you can give me a hint when I wrote something wrong. I hope someone can help me.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void reset_Click(object sender, EventArgs e)
{
textBox.Text = "";
}
private void button_Click(object sender, EventArgs e)
{
textBox.Text = "Button";
}
private void nothing_Enter(object sender, EventArgs e)
{
textBox.Text = "nothing";
}
}
}
Form1.Designer.cs
this.reset.Click += new System.EventHandler(this.reset_Click);
this.button.Click += new System.EventHandler(this.button_Click);
this.nothing.Enter += new System.EventHandler(this.nothing_Enter);