How can I return the key?, mean if I want to allow only integer values in the textbox, how can I don\'t allow user to not enter non-integers, regarding, KeyPress
KeyPress
For WPF, use the PreviewTextInput event with code like:
// Filter out non-numeric keys. private void MyApp_PreviewTextInput(object sender, TextCompositionEventArgs e) { String sKeys = "1234567890"; if (!sKeys.Contains(e.Text)) e.Handled = true; }