[Gambas-user] Gambas-user Digest, Vol 107, Issue 12

Martin McGlensey mmcg29440 at ...3163...
Wed Apr 15 14:08:09 CEST 2015


Marce,

Appreciate your suggestion. But, I'm totally confused by your explanation. I
do not know how to implement it. Could you provide an example? Send it as an
attachment to N3MOW at ...3467... That way I'll get it. The intent is to read
the datasource.table   property on form A for use in form B and to assign
the datasource to a datasource object on form B. No changes need be made to
the datasource properties on form A.

Marty



Message: 1
Date: Tue, 14 Apr 2015 11:48:02 -0300
From: ML <d4t4full at ...626...>
Subject: Re: [Gambas-user] Reading control properties from a
	collection
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Message-ID: <552D28A2.8040305 at ...626...>
Content-Type: text/plain; charset=windows-1252

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
********************************************





More information about the User mailing list