Child Forms and Parent forms mismatch in Vb.net -


i have parent form called mdiform1 within open frm1 child form. great @ point - need open form within frm1 - lets call frmx , here's issue arises - had declared mdichild form, , did mdichild.show - issue comes because when form opens (it covers 1/3 of frm1 - open) , user clicks outside of frmx - disapears. tried .showdialog() unable because it's not top level , mdichild therefore won't let me .showdialog(). here's code...

    private sub cmd1_click(sender object, e eventargs) handles cmd1.click      dim newmdichild new frmx()      'set parent form of child window.     newmdichild.mdiparent = mdi1      'display new form     newmdichild.showdialog()      newmdichild.top = 310     newmdichild.left = 36     newmdichild.width = 897 end sub 

i error on .showdialog() , here's says....

form not top-level form cannot displayed modal dialog box. remove form parent form before calling showdialog.

i tried declare frmx this....

dim frmx new form frmx.showdialog  'specifying top/left/width doesn't anything, opens empty form elsewhere on screen. 

edit:it's little confusing :/

this did - getting same error. in frm1 on button click suppose open frmx in modal users clicking on frm1 not make frmx disappear. opens in right location when click elsewher on frm1 --- frmx disappears

    dim frmxname new frmx()     frmxname.mdiparent = me.mdiparent     frmxname.showdialog()     frmxname.top = 310     frmxname.left = 36     frmxname.width = 897 

my goal have frmx open until click close on it!

set new form's mdi parent controlling form's mdi parent

in mdi parent called form1. form has property ismdicontainer = true

public class form1      private sub form1_load(sender object, e eventargs) handles mybase.load         dim myfrmx new frmx         myfrmx.mdiparent = me         myfrmx.show()     end sub  end class 

and in frmx button on it

public class frmx       private sub button1_click(sender object, e eventargs) handles button1.click         dim f new form         f.mdiparent = me.mdiparent         f.text = "frmy"         f.show()     end sub  end class 

clicking button creates new forms, shown mdi children of main form below

enter image description here

or if want dialog window, forgo mdi business, , show dialog

public class frmx       private sub button1_click(sender object, e eventargs) handles button1.click         dim f new form         f.text = "frmy"         f.showdialog()     end sub  end class 

now frmy has focus until it's closed.

enter image description here


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -