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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -