textbox validation for allow one “ . ” value c#

后端 未结 8 1622
悲&欢浪女
悲&欢浪女 2021-01-23 08:56

I want textbox validation for allowing only one . value and only numbers. Means my textbox value should take only numerics and one . value. Value shoul

8条回答
  •  感情败类
    2021-01-23 09:36

    Also try this short one

    e.Handled = (!(e.KeyChar == (char)Keys.Back || e.KeyChar == '.')); //allow  dot and Backspace
    e.Handled = (e.KeyChar == '.' && TextBox1.Text.Contains(".")); //allow only one dot
    

    this example only allow one dot and backspace

提交回复
热议问题