Numeric TextBox

后端 未结 13 1107
再見小時候
再見小時候 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条回答
  •  天命终不由人
    2020-12-03 20:34

    As far as I am aware there's nothing native in the .NET framework (2.0 at least) to do this. Your options would be:

    1. Create a custom control which inherits from the textbox control and only allows numeric input. This has the advantage that the control can be reused.
    2. Handle the KeyPress event and check the charCode to only allow numeric keystrokes. This is easier but much less reusable.

提交回复
热议问题