Passing data between forms
-
Hello, I need some sound advice, here is the scenario: I have a mdiChild form that contains a button that launches a owned (owned by the mdiChild) form. My questions is: What is the most effective way to pass data from the owned form to the appropriate member variables declared on the mdiChild form (owner)? Thanks in advance, Andrew
-
Hello, I need some sound advice, here is the scenario: I have a mdiChild form that contains a button that launches a owned (owned by the mdiChild) form. My questions is: What is the most effective way to pass data from the owned form to the appropriate member variables declared on the mdiChild form (owner)? Thanks in advance, Andrew
It's alright I figured it out. I created a custom constructor for the owned form that accepts an instance of the mdiChild form. Example: (Owned Form Declaration) Public Sub New(ByRef mdiChildInstance As frmMdiChild) MyBase.New() _mdiChildInstance = mdiChildInstance End Sub (OwnedForm Instantiation - code is located on the MdiChild Form) Public OwnedForm As New frmOwnedForm(Me) I also created public properties for all of the member variables on mdiChild. Does anyone see any red flags with the code above? Thanks, Andrew
-
It's alright I figured it out. I created a custom constructor for the owned form that accepts an instance of the mdiChild form. Example: (Owned Form Declaration) Public Sub New(ByRef mdiChildInstance As frmMdiChild) MyBase.New() _mdiChildInstance = mdiChildInstance End Sub (OwnedForm Instantiation - code is located on the MdiChild Form) Public OwnedForm As New frmOwnedForm(Me) I also created public properties for all of the member variables on mdiChild. Does anyone see any red flags with the code above? Thanks, Andrew
:wtf::wtf::wtf::wtf::wtf:The memory footprint of this kind of coding is a serious problem.
-
:wtf::wtf::wtf::wtf::wtf:The memory footprint of this kind of coding is a serious problem.
So what is your suggestion?
-
:wtf::wtf::wtf::wtf::wtf:The memory footprint of this kind of coding is a serious problem.
Why is it a serious problem? A form is just a class, and it's common practice to create and pass values to custom constructors, correct? Andrew
-
Why is it a serious problem? A form is just a class, and it's common practice to create and pass values to custom constructors, correct? Andrew
A form is a class, but once instanciate it is an object that ocupies memory space. The bigger the object, the bigger the cost of passing it through constructors. Yes, if you pass it by reference instead you eliminate some of that cost because the CLR does not create a copy of the object. But it is better practice to pass smaller objects through constructors.
-
A form is a class, but once instanciate it is an object that ocupies memory space. The bigger the object, the bigger the cost of passing it through constructors. Yes, if you pass it by reference instead you eliminate some of that cost because the CLR does not create a copy of the object. But it is better practice to pass smaller objects through constructors.
Thank you for the explanation. What you're saying makes absolute sense. Your help is much appreciated. Thanks again, Andrew P.S What is a better way to pass data between mdiChild forms?