vb.net - Form keydown event and textbox keydown event -
private sub accounttype_keydown(sender object, e keyeventargs) handles mybase.keydown if e.keycode = keys.return processtabkey(true) end if end sub private sub anytextbox_enter(sender object, e eventargs) handles twitter.enter, email.enter, phonenooffice.enter, phonenohome.enter, phonenomobile.enter, ename.enter, aname.enter, idcode.enter, expirydate.enter, bankaccount.enter dim txt textbox = directcast(sender, textbox) stroldvalue = txt.text end sub private sub anytextbox_keydown(sender object, e keyeventargs) handles twitter.keydown, email.keydown, phonenooffice.keydown, phonenohome.keydown, phonenomobile.keydown, ename.keydown, aname.keydown, idcode.keydown, expirydate.keydown, bankaccount.keydown dim txt textbox = directcast(sender, textbox) if e.keycode = keys.enter or e.keycode = keys.tab if txt.text <> stroldvalue connectunauth() cmd = new sqlcommand("insert changes values(@id,@txtname,@oldval,@newval)", variables.unauthcon) cmd.parameters.addwithvalue("@id", customerno.text) cmd.parameters.addwithvalue("@txtname", txt.name) cmd.parameters.addwithvalue("@oldval", stroldvalue) cmd.parameters.addwithvalue("@newval", txt.text) cmd.executenonquery() unauthcon.dispose() nochange = true end if end if end sub
in above code face following error: on entry 1 textbox, value saved in stroldvalue. on pressing enter after changing in above, form_keydown event triggers first, runs anytextbox_enter event causing stroldvalue overwritten next textbox value. , textbox keydown event triggers.
i tried keypress event form, keypress event not capture enter key press on combobox. should keydown of form triggers after textbox keydown event.
Comments
Post a Comment