decrypt Posted July 5, 2004 Posted July 5, 2004 This is what i have: first i have a main form, and this is the only code in it: Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim frm1 As New Form1 frm1.MdiParent = Me frm1.Show() End Sub That opens up form1 to be the mdichild of form 'Main'. In form 1 i have this code: Dim chatD As New ChatForm chatD.MdiParent = frmMain chatD.Text = "Chat" chatD.Show() The only problem is that the above code doesn't open it up as an mdiChild of form 'Main'. How could i make form1 open up chatform as an mdiChild of form 'Main'? Thanks in advanced! :) Quote
Administrators PlausiblyDamp Posted July 5, 2004 Administrators Posted July 5, 2004 Is the Main forms IsMdiContainer property set to true? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Administrators PlausiblyDamp Posted July 11, 2004 Administrators Posted July 11, 2004 Main is the MDI PArent - correct? Form1 is a child of the Main form - also correct? ChatForm is another child of the Main form - correct? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Wile Posted July 11, 2004 Posted July 11, 2004 Dim chatD As New ChatForm chatD.MdiParent = frmMain [/quote] Maybe the frmMain reference isnt working properly. I dont know how VB.NET handles references to forms using the class name (last time VB for me is VB 6 a couple of years back ;) ). frmMain is the form name, not the name of a variable containing the form. It could be that using this construction, VB creates a new frmMain internally, so the chatD.MdiParent refers to an object that is a second instance of the frmMain. To work around this you would have to make sure you give the chatD form the same reference you use. That shouldnt be to difficult, I think the following would do that trick. [code] chatD.MdiParent = me.MdiParent That would guarantee you reference to the correct form. Quote Nothing is as illusive as 'the last bug'.
decrypt Posted July 16, 2004 Author Posted July 16, 2004 (edited) Main is the MDI PArent - correct? Form1 is a child of the Main form - also correct? ChatForm is another child of the Main form - correct? yes that is correct. Maybe the frmMain reference isnt working properly. I dont know how VB.NET handles references to forms using the class name (last time VB for me is VB 6 a couple of years back ;) ). frmMain is the form name, not the name of a variable containing the form. It could be that using this construction, VB creates a new frmMain internally, so the chatD.MdiParent refers to an object that is a second instance of the frmMain. To work around this you would have to make sure you give the chatD form the same reference you use. That shouldnt be to difficult, I think the following would do that trick. chatD.MdiParent = me.MdiParent That would guarantee you reference to the correct form. edit: ah... now i get what your saying. (it took a while for it to click.) Thanks i'll see if that works :) Edited July 16, 2004 by decrypt Quote
decrypt Posted July 16, 2004 Author Posted July 16, 2004 IT WORKED!! The chatP.MdiParent = me.MdiParent worked!! Thanks alot :) I can now get back to work on this. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.