c# - Modal form does dismiss upon close -


i have modal form form1. there button, when users click it, modal form shows formchild. if there error, want dismiss formchild , display messagebox. use following code. however, see messagebox displays on top of formchild.
how make formchild disappear/close?

        formchild.dialogresult = dialogresult.cancel;         formchild.close();         messagebox.show(error, "error", messageboxbuttons.ok, messageboxicon.stop);  

why not put "if" statement before call formchild?

//some codes here: if (!error)     formchild.showdialog(); else     messagebox.show("error has occured."); 

or if that's not possible, try putting if statement in formchild.load.

      private void formchild_load(object sender, eventargs e)   {        //some codes here:            if (error)            {                                         messagebox.show("error has occured.");                 this.close();            }   } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -