c# - Windows Form tabpage event -
i have windows form application , in created 2 tab pages. in 1 of tab page have button send email notification. in tabpage leave event have code perform other actions. when click on button send email. first fires tabpage leave event , ithe button contains button1.enabled=false; in first line below,
private void btntestemail_click(object sender, eventargs e) { btntestemail.enabled = false; bool sent = support.sendemail("test email", "this test email, please ignore.", null); -- }
but when remove btntestemail.enabled = false; code not firing tabpage leave event. reason fires leave event of tab page. vbery strange behaviour. dont want fire event of tab page .
regards
changing btntestemail.enabled
false change activecontrol
, fires leave
event.
according msdn:
when change focus using keyboard (tab, shift+tab, , on), calling select or selectnextcontrol methods, or setting containercontrol.activecontrol property current form, focus events occur in following order:
enter
gotfocus
leave
validating
validated
lostfocus
what can do:
what eliminate behavior unsubscribing leave
event , re-subscribing after setting enabled
property false.
like this:
this.tabpage1.leave -= new system.eventhandler(this.tabpage1_leave); btntestemail.enabled = false; this.tabpage1.leave += new system.eventhandler(this.tabpage1_leave);
Comments
Post a Comment