Numeric TextBox

后端 未结 13 1121
再見小時候
再見小時候 2020-12-03 20:01

Im new to programming and I dont know very much about but I\'m making a calculator, and i want to use a textbox that only acepts numbers and decimals, and when the user past

13条回答
  •  旧时难觅i
    2020-12-03 20:40

    The easiest way :)

    on Keypress event on your textbox


    if ((e.KeyChar <= 57 && e.KeyChar >= 48) || e.KeyChar == 13 || e.KeyChar == 8)
    {
    }
    else
    {
         e.Handled = true;
    }
    

提交回复
热议问题