Make Textbox Number Only – WPF

Coding :

private void txt_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !ValidNumeric(e.Text);
base.OnPreviewTextInput(e);
}
 
bool ValidNumeric(string str)
{
bool ret = true;
 
int l = str.Length;
for (int i = 0; i < l; i++)
{
char ch = str[i];
ret &= Char.IsDigit(ch);
}
 
return ret;
}

Thanks dedjo

Popularity: 5% [?]

Related posts:

  1. Encrypting string value using MD5 in PHP
  2. Sorting Program using C#
  3. Create a Stored Procedure within a Stored Procedure
You can leave a response, or trackback from your own site.

One Response to “Make Textbox Number Only – WPF”

  1. Thanks for that! lol… so I’m still wondering what you concept for the post I produced last week, you by no means did comment on it??

Leave a Reply

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars