Hello world! I am requiring some assistance with my C# program, where I am getting an error message for having a form where the user would enter in text into a text box. I am trying to detect if the user has pressed the Enter key, and on doing so would produce a message box with a message. However, I am trying to call the "KeyEventArgs" class which would allow me to detect the key press, but receive the following error message:
No overload for 'TextBox_KeyDown' matches delegate 'System.EventHandler'
Here is my code for the TextBox I am using:
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
MessageBox.Show("You have entered the correct key.");
}
}
Clicking on the error message for further details, leads me to the Designer class for the form I am using, and underlines the following text:
this.TextBox.KeyDown += new System.EventHandler(this.TextBox_KeyDown);
Any help would be much appreciated. Thanks!