I'd like to call a KeyEvent from within an Event. Something like...
private void txtPostcode_TextChanged(object sender, EventArgs e)
{
TxtboxNumbersOnly(sender, e);
}
Where TxtboxNumbersOnly is a KeyEvent. However it isn't allowed. I've also tried casting but it is giving an error. What would be the correct way of doing this?
Thanks, Grant. A snippet follows..
private void TxtboxNumbersOnly(object sender, KeyEventArgs e)
{
//Allow arrow keys
switch (e.KeyCode)
{
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
case Keys.PageUp:
case Keys.PageDown:
case Keys.Delete:
e.SuppressKeyPress = false;
return;
The error is:
Argument2:cannot convert from 'System.EventArgs' to 'System.Windows.Forms.KeyEventArgs'.