Answers for "wpf numeric only textbox"

C#
1

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);
}
Posted by: Guest on June-23-2021

C# Answers by Framework

Browse Popular Code Answers by Language