Created
December 31, 2014 05:17
-
-
Save hbsnow/ecda9da7083e50abfc06 to your computer and use it in GitHub Desktop.
数値入力に必要なキー以外を無効化する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void KeyPressNumberOnly(Object sender, KeyEventArgs e) | |
{ | |
if ((e.Key < Key.D0 || e.Key > Key.D9) && | |
(e.Key < Key.NumPad0 || e.Key > Key.NumPad9) && | |
e.Key != Key.Back && | |
e.Key != Key.Delete && | |
e.Key != Key.Left && | |
e.Key != Key.Right && | |
e.Key != Key.Tab) | |
{ | |
e.Handled = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment