Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

wpf numeric only textbox

<TextBox Name="NumberTextBox" PreviewTextInput="NumberValidationTextBox"/>

-------------------------------------------------------------------------------

using System.Text.RegularExpressions;
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
    Regex regex = new Regex("[^0-9]+");
    e.Handled = regex.IsMatch(e.Text);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wpf #numeric #textbox
ADD COMMENT
Topic
Name
5+1 =