c# - WinForms firing Enter event twice -
i've got following:
private void fooform_enter( object sender, eventargs e ) { foobar() } private void foobar() { console.out.writeline( "foo" ); /* stuff */ othercontrol.focus(); }
the problem i'm experiencing here see text in console twice, though put focus on fooform once. however, if comment out othercontrol.focus() line, foobar called once. (no, othercontrol not same object fooform.)
what causes , can make sure foobar called once?
according msdn documentation:
do not attempt set focus within enter, gotfocus, leave, lostfocus, validating, or validated event handlers. doing can cause application or operating system stop responding.
you appear doing that.
Comments
Post a Comment