Board index » Visual Studio » Issue Loading a Form from it's Parent...

Issue Loading a Form from it's Parent...

Visual Studio79
Hi there,



I'm having a hard time figuring out why is this happening. The problem is a

couple of variables are not getting properly initialized when I load a

FormX from it's parent form.



I have the main form (parent) as the startup object for the project. When I

load the FormX from a menu from the main form (parent) and here is where

these two variables are not gettting initialized properly. This is the code

that calls the FormX from the main menu ;



Dim FormX As New frmTest



FormX.MdiParent = Me



'Display the new form.



FormX.Show()



Now the two variables are these;

Private Shared m_FormDefInstance As frmSomeForm



Private Shared m_InitializingDefInstance As Boolean



the first variable m_FormDefInstance Should be =

ApplicationName.frmSomeForm. now, when I load FormX from it's parent, with

the code above, the first variable = nothing!! but when I change the start

up object to the FormX, then they properly initialized.



Now can anybody guide me on the right direction on how to load FormX so the

these variables are set properly at loading time.



I don't know if I'm explaining things properly here, if you need me to be

more specific here, please let me know.



Thanks for your help on this one.



Manny


-
 

Re:Issue Loading a Form from it's Parent...

Hey Manny



I think your a bit muddled mate. Why would m_FormDefInstance of type

frmSomeForm return anything

when you Dim up a new frmTest into a variable named FormX?



Assuming frmTest is a subclass of frmSomeForm, you should be coding

something more like

m_FormDefInstance = New frmTest.



What you are trying to do is incredibly easy but its hard to be more

specific without a complete code dump so we can see the context of calls.

Show us your complete Constructor/OnLoad event for the parent form.



hth

Richard





"Manuel Canas" <mcanasc@hotmail.com>wrote in message

Quote
Hi there,



I'm having a hard time figuring out why is this happening. The problem is

a

couple of variables are not getting properly initialized when I load a

FormX from it's parent form.



I have the main form (parent) as the startup object for the project. When

I

load the FormX from a menu from the main form (parent) and here is where

these two variables are not gettting initialized properly. This is the

code

that calls the FormX from the main menu ;



Dim FormX As New frmTest



FormX.MdiParent = Me



'Display the new form.



FormX.Show()



Now the two variables are these;

Private Shared m_FormDefInstance As frmSomeForm



Private Shared m_InitializingDefInstance As Boolean



the first variable m_FormDefInstance Should be =

ApplicationName.frmSomeForm. now, when I load FormX from it's parent, with

the code above, the first variable = nothing!! but when I change the start

up object to the FormX, then they properly initialized.



Now can anybody guide me on the right direction on how to load FormX so

the

these variables are set properly at loading time.



I don't know if I'm explaining things properly here, if you need me to be

more specific here, please let me know.



Thanks for your help on this one.



Manny









-