PlayKid Posted June 25, 2005 Posted June 25, 2005 Hi all, I would like to know, how do I create a form within a form, say for example I have created a main form, which contains all the controls, and also, some other forms that is within the application, all the maximization, minimization, resizing are all happened in the main form. Thanks PlayKid Quote
decrypt Posted June 25, 2005 Posted June 25, 2005 set the main form to IsMDIContainer and you can define other forms as MDIChilds: Main Form: 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 And set IsMDIContainer = true Quote
PlayKid Posted June 26, 2005 Author Posted June 26, 2005 set the main form to IsMDIContainer and you can define other forms as MDIChilds: Main Form: 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 And set IsMDIContainer = true Hi, I have tried your method, but it seems not working, here is my code Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim mainfrm As New MainForm mainfrm.MdiParent = Me mainfrm.Show() End Sub The error is that the form cannot be both MdiChild and MdiParent, can you tell me how to solve it? Quote
PlayKid Posted June 26, 2005 Author Posted June 26, 2005 ok...I solved it now.... Thanks alot.. Quote
decrypt Posted June 26, 2005 Posted June 26, 2005 it seemed like you were trying to load the form it was being loaded in :P Quote
PlayKid Posted July 3, 2005 Author Posted July 3, 2005 I had another problem, I got the main form to load a mdichild form fine, but when I am trying to load another from the mdichild form, it doesn't work. Can you teach me now? ie. I had a main form, I loaded a second form when I clicked a button from the main form, then I had another button on the second form, which load the third form, but can the third form do all the maximization and minimization within the main form? Thanks Quote
jmcilhinney Posted July 4, 2005 Posted July 4, 2005 The new form must have the original parent form as its parent too, so in the second form you would have to use code like this:Dim newForm As New Form3 newForm.MdiParent = Me.MdiParent newForm.Show() Quote
PlayKid Posted July 4, 2005 Author Posted July 4, 2005 I have another method on this too.... the code that I got is Dim newForm As New Form3 newForm.MdiParent = ParentForm newForm.Show() That also work.....but well, my version and yours are pretty similar.... Quote
jmcilhinney Posted July 4, 2005 Posted July 4, 2005 I have another method on this too.... the code that I got is Dim newForm As New Form3 newForm.MdiParent = ParentForm newForm.Show() That also work.....but well, my version and yours are pretty similar....It works as long as you have declared a variable called ParentForm and assigned the parent form to it, but why do that when you already have the MdiParent property? The advantage might be that your variable would be of the correct specific type whereas MdiParent is of type Form, which would require a cast to use members of the derived class. If you don't use those members, however, it serves no purpose. Quote
PlayKid Posted July 7, 2005 Author Posted July 7, 2005 Nono.....the ParentForm is something from the VB.Net, I didnt declared anything as the Parent Form. I found this thing out from VB.Net Help. Quote
jmcilhinney Posted July 7, 2005 Posted July 7, 2005 Nono.....the ParentForm is something from the VB.Net, I didnt declared anything as the Parent Form. I found this thing out from VB.Net Help.So it is. My apologies. 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.