vb.net - Restriciton in combobox should not delete text in combox -


combobox should not accept inputs , backspace. code accepts backspace.

 private sub combobox5_keypress(byval sender object, byval e system.windows.forms.keypresseventargs) handles combobox5.keypress      if asc(e.keychar) <> 13 , asc(e.keychar) <> 8 , not isnumeric(e.keychar) or isnumeric(e.keychar)          e.handled = true     end if end sub 

your description , code posted don't match well. going assume left words out, , want allow cr, bksp, , numeric. looks want numbers combobox.

as vincent said, if statement confusing. "not isnumeric(e.keychar) or isnumeric(e.keychar)" evaluates true, it's or not a.

for numbers in comboboxes, method, though there lots of ways skin cat:

private sub combobox5_keypress(sender object, e keypresseventargs) handles combobox5.keypress     select case ascw(e.keychar)         case 13             'do whatever need cr here          case 8,     3,   22,   24, 26             'backsp copy paste cut undo             'let 'em          case else             e.handled = not isnumeric(e.keychar)      end select end sub 

if didn't want backspace, delete 8 case statement, or whole case statement if don't want user edit text @ all.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -