c# - Glimpse of Background window shown when new Form is displayed -
i have main form.i invoke form2 mainform using form2.showdialog(application.openforms["mainform"]);
invoke form form2
this.hide(); form3.showdialog(application.openforms["mainform"]); this.dispose();
everything works fine when form3 displayed glimpse of window displayed in background ie:if had opened ms paint put in background paint window come on top of window time less second , automatically go backgroud. why behavior.how can correct it?
when call this.hide()
, form2 hidden , window needs focused. however, opened form2 showdialog, means form2 window can focused in application. since hid form2, windows finds window focus (in case ms paint).
one suggestion solution artificially give mainform focus before hiding form2:
application.openforms["mainform"].activate(); this.hide(); form3.showdialog(application.openforms["mainform"]); this.dispose();
perhaps more beautiful solution first open form3, wait shown, , hide form2. this, put code in form2, when want show form3:
form3.shown += (_s, _e) => application.openforms["form2"].hide(); form3.showdialog(application.openforms["mainform"]); this.dispose();
Comments
Post a Comment