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
give name control ex. "tabedtextbox"
add textbox control user control
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
compile once in order update whole project new user control.
goto form , add new user control, can locate @ toolbox panel.
run program , see behavior of tab when press enter on each textbox.
Comments
Post a Comment