using System.Text.RegularExpressions;
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsTextAllowed(e.Text);
}
private static bool IsTextAllowed(string text)
{
Regex regex = new Regex(“[^0-9.-]“);
return !regex.IsMatch(text);
}
//use above code in textbox “PreviewTextInput” EVENT
Posted by raxaview