Below is the code for keydown and validating. If i have two entries in my invokeApp arraylist, and i enter "2" as my choice, the second app runs, and when i return the validating function fires and blanks out teh text entry box. perfect! BUT if i enter "3" as my choice, the keydown function correctly realises that it shouldn't run an app, so it does nothing. That's good, but it also doesn't fire the validating function, so the text box remains populated with "3", until I type a valid number. How can I get it to fire validating?





private void txtChoice_KeyDown(object sender, KeyEventArgs e)
{
//MessageBox.Show("key - 49 " + (e.KeyValue - 49) + " count " + invokeApp.Count);
if (e.KeyCode >= Keys.D1 && e.KeyCode <= Keys.D5)
{ //make sure they entered int between 1 and 5
if ((e.KeyValue - 49) < invokeApp.Count)
{//make sure they didn't key an int for an option that isn't there
//MessageBox.Show("key value = " + e.KeyValue);
//the value of key 1 is 49, 2 is 50, etc. subtract 49 to get int 0-4
appPathAndName = @"\Program Files\" + (string)invokeApp[e.KeyValue - 49];
Process.Start(appPathAndName, "");
}
else
{
e.Handled = true;
}
}
else
{
e.Handled = true;
}
}

void txtChoice_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
if (txtChoice.Text.Length > 0)
{
txtChoice.Text = "";
txtChoice.Focus();
e.Cancel = true;
}
}