Single code for Tab Key functionality using Enter Key in Vb.Net for a Windows Application -


i write code tab-like behavior when user presses enter on textboxes every form, works fine.

    if e.keychar = microsoft.visualbasic.chrw(keys.return)         sendkeys.send("{tab}")         e.handled = true     end if 

however, need write code once, perhaps sub or function in module not have write same every form. have checked various forums including detecting enter keypress on vb.net , tab key functionality using enter key in vb.net either write code each textbox or every individual form. has tried out single code or may several selected forms of application? if yes, please share me. writing every form still works fine me need take advantage of oop. thanks

there many ways implement this, 1 of create custom textbox user control

adding control project easy right click in project in solution explorer ->add->user control enter image description here

give name control ex. "tabedtextbox" enter image description here

add textbox control user control enter image description here

place code in keypress event of textbox1 of usercontrol

 private sub textbox1_keypress(sender object, e keypresseventargs) handles textbox1.keypress         if e.keychar = microsoft.visualbasic.chrw(keys.return)             sendkeys.send("{tab}")             e.handled = true         end if     end sub 

enter image description here

compile once in order update whole project new user control.

goto form , add new user control, can locate @ toolbox panel. enter image description here

run program , see behavior of tab when press enter on each textbox.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -