How to make a textbox that only accepts number and decimal points in c# ?
looking for something very simple if anyone knows please help !
How to make a textbox that only accepts number and decimal points in c# ?
looking for something very simple if anyone knows please help !
 
    
    try this code...
 if (!(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || e.KeyChar == '.'))
            { e.Handled = true; }
            TextBox txtDecimal = sender as TextBox;
            if (e.KeyChar == '.' && txtDecimal.Text.Contains("."))
            {
                e.Handled = true;
            } 
    
    I think you are looking for a Masked TextBox. Create one, and put this Regex into the Mask section: ^(\d+)?+([\.]{1})?+([\d]{1,2})?$
