forms
-
Hi I have a mainform that opens up another form 'A'. By doing something on form 'A', opens up form 'B'. Both forms 'A' and 'B' should have access to the instance and fields of the mainform. What is the best approach? This is not MDI. Should it be? Can MDI be avoided in this case?
-
Hi I have a mainform that opens up another form 'A'. By doing something on form 'A', opens up form 'B'. Both forms 'A' and 'B' should have access to the instance and fields of the mainform. What is the best approach? This is not MDI. Should it be? Can MDI be avoided in this case?
One way is to have each opening form pass an instance of itself to the form it opens and have that new form store that instance. If you want to access you form class's methods and properties, define the field in the new form as the type of your form and not simply
Form
(otherwise you'll have to cast your field to the right type before calling non-overridden methods and properties). Such a property does already exist and allows owned forms to be minimized and restored along with the owning form. Read the documentation[^] for theForm.Owner
property for more information. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]