Get the value of the textbox on c# <p>I'm working on a wpf app and i want to get the value of textbox i want to use KeyDown &amp; KeyPress to check if the text is a numeric value but when i write KeyPress the compilator underlined the proprity so i can't use it . </p> <pre><code>private void sb_KeyDown_1(object sender, System.Windows.Input.KeyEventArgs e) { nonNumberEntered = false; // Determine whether the keystroke is a number from the top of the keyboard. if (e.KeyCode &lt; Keys.D0 || e.KeyCode &gt; Keys.D9) { // Determine whether the keystroke is a number from the keypad. if (e.KeyCode &lt; Keys.NumPad0 || e.KeyCode &gt; Keys.NumPad9) { // Determine whether the keystroke is a backspace. if (e.KeyCode != Keys.Back) { // A non-numerical keystroke was pressed. // Set the flag to true and evaluate in KeyPress event. nonNumberEntered = true; } } } //If shift key was pressed, it's not a number. if (Control.ModifierKeys == Keys.Shift) { nonNumberEntered = true; } } </code></pre> <p>and it underlined also e.KeyCode and e.KeyNumPad0 .... what should i do ?</p>