Why does TextBox only let users input shapes?
Overwrite keyboard events on KeyPress ()
By overriding the OnKeyPress () event of the TextBox control, you can handle the characters entered by the keyboard, as shown in the following code:
//Block non-numeric keys
Protected coverage void on keypress (keypress eventargse) {
Base. Key (e);
//Read only, do not process
If (this. Read only)
{Return; }
//Special keys (including spaces) will not be processed.
if((int)e . key char & lt; = 32)
{Return; }
//Non-numeric keys, give up input.
If (! Charles. IsDigit(e.KeyChar))
{e. Handled = true returns; }
}
How to let users only input more than 5 digits?
It should be enough to set the minlength property of textbox, or take the input string to judge whether the length is less than 5, and then you will be prompted.