Control the input character of the Textbox box

zhaozj2021-02-16  84

2004.7.9

Using the TextBox control in the VS2003, then make a subclass of this control, mainly for only the functionality of the amount number. After attempting, it is found that after the onkeypress method is covered in the subclass, it can control whether the characters are allowed to be entered. Protected Void OnKeyPress (Object sender, keypressEventArgs e) {// determined if the input is 0 if (E.KEYCHAR == '0') {// is 0, the processing of the keypress event is set to end. // At this time, 0 characters are not entered into TextBox. E.handled = true;} else {e.handled = false;} return;}

转载请注明原文地址:https://www.9cbs.com/read-13394.html

New Post(0)