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.

Comments

  1. Maybe i did not understand what you mean, but..
    One 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.

    ReplyDelete
  2. That's what I thought of. But from the subform i was not able to adress the mainform variable.... 😢
    Unfortunately I don't have my source with me at the moment. I will try IT again tomorrow.
    Thanks so far

    ReplyDelete
  3. 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.

    ReplyDelete
  4. In your subform, you must ade the mainform in the "Users" section

    ReplyDelete
  5. Thanks for your help. Like I already wrote in the main question I had a total blackout. 
    added the unit and addressed the correct object. now it works :-)

    ReplyDelete

Post a Comment