[Gambas-user] Reading control properties from a collection

ML d4t4full at ...626...
Tue Apr 14 16:48:02 CEST 2015


Marty,
Never a good idea to dirty your fingers poking a form's controls from
another one. Been there, done that, regretted it for a looooong time.

I'd do this instead, and it's a general-purpose approach that served me
well for a long time, no matter the cross-forms (or even cross-class)
data you need:

In the form (call it *frmA*) that has the data the other form (call it
*frmB*) needs, I'd publish the necessary data as appropriate type's
*Public Property*(*ies*).
I would also -if necessary- set up some kind of *Event* in *frmA* that
triggers when the sought data changes.

Then, in *frmB*, I'd *Dim* a *Private* *Object* of type *frmA* and
instance and show it whenever necessary.
In *frmB*'s event handler for *frmA*'s event -or in code, your call- I'd
check the *Public Property*(*ies*) of *frmA*.

Doing it this way not only isolates your data access from the underlying
implementation, but also you can radically change HOW you access data to
be published in *frmA* while not touching *frmB* at all.
Then, you may fetch data in *frmA* from a database, flat file or TCP
socket, and *frmB* will function the same, no code mods necessary. An
additional advantage is no time wasted on for-loops.

HTH,
zxMarce.

*On 14/Apr/2015 11:00, Martin McGlensey wrote:*
Hello,
I have a form that contains a named datasource. I want to read the name
and table properties of that datasource from another form. Both forms
are visible.
I've used the loop "For each hWindow in Windows" to test to see if the
form is visible. If it is I cycle through the control collection for
that form till I find an Object.Type = "DataSource". So far so good - I
can find the datasource and assign it to a variant variable (DataTable).
Now if I do strX = DataTable.Name it returns "DataSource1"  instead of
"Neighborhood" the name of the datasource on the form containing the
collection.
I want to get to the datasource name and table from the first form. They
should be name=neighborhood and table=tblneighborhood. If I assign
frmEntry.Neighborhood to datatable on the second form then I get the
correct data returned. I think it should be possible to get this data
from the forms collection but, I have not figured out how.
So can it be done and if so how?
Regards,
Marty
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user



More information about the User mailing list