Only a number of input numbers in the text box

xiaoxiao2021-03-30  209

Only a number of input numbers in the text box

Button's KeyPress event

Private

Void

Button_KeyPress

Object

Sender, keypressEventArgs e) {

charr

[] Charnum

=

{

'

0

'

,

'

1

'

,

'

2

'

,

'

3

'

,

'

4

'

,

'

5

'

,

'

6

'

,

'

Seduce

'

,

'

8

'

,

'

9

'

, '/ u0008', '/ u000d'};

IF

(Array.indexof (Charnum, E.Keychar)

<

0

) {E.handled

=

True

}}

Can only prevent keyboard input .. Can not be pasted ....

Set the Button's shortcutsenabled attribute to false ... You can disable right-click pastry and copy

VS2005 has a better control to limit the input content ...

MaskedTextBox, just set the mask attribute

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

New Post(0)