Hello everybody
Hello everybody,
I seem to have a total blackout.... :-(
Can someone send me a link to a how-to in which is described, how I can get an object that I have defined in an extra unit to be used in different Forms.
Now I want to set and get properties from an object created in my mainform in different subforms.
Seems like I am missing something there.
I just need a place where I can read into it.
Thanks in advance.
I seem to have a total blackout.... :-(
Can someone send me a link to a how-to in which is described, how I can get an object that I have defined in an extra unit to be used in different Forms.
Now I want to set and get properties from an object created in my mainform in different subforms.
Seems like I am missing something there.
I just need a place where I can read into it.
Thanks in advance.
Maybe i did not understand what you mean, but..
ReplyDeleteOne solution would be to add a public variable/property of type "MyObject" in your mainform and create the object on OnCreate event. Then you can access it from a subform trough the mainform, per example: MainForm.MyObject.ObjectPropertyOrFunction. Do'nt forget to free the object on OnDestroy Event of the Mainform.
That's what I thought of. But from the subform i was not able to adress the mainform variable.... 😢
ReplyDeleteUnfortunately I don't have my source with me at the moment. I will try IT again tomorrow.
Thanks so far
Frank Duchna If you make the object on the main form public, there should be no problem accessing it from sub-forms. Alternately, if you pass a reference to the main form object into your subforms, then the visibility in the main form should not be a barrier, either.
ReplyDeleteIn your subform, you must ade the mainform in the "Users" section
ReplyDeleteThanks for your help. Like I already wrote in the main question I had a total blackout.
ReplyDeleteadded the unit and addressed the correct object. now it works :-)