Marty, First off, sorry for the delay. I made a how-to example, but I'd prefer to also post it to the list so everybody else can benefit from it. Please find it attached. Loads of comments, little code. It's really surprising (and relieving) to see how easy it actually is! Please check not only the comments in code, but the project description as well.
As a side note, I'd like to ask the mods -if appropriate- to include it in the How To wiki (or anywhere else they seem adequate). Inter-class data passing is easy to implement, but there is a lack of examples in the Wiki and Help. Moreover the event sink routine naming scheme is a bit obscure but obvious once you figure it out, yet no examples found in the official docs. HTH, zxMarce. *On 15/Apr/2015 09:08, Martin McGlensey wrote:* > 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 n3...@arrl.net. 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 <d4t4f...@gmail.com> > Subject: Re: [Gambas-user] Reading control properties from a collection > To: mailing list for gambas users <gambas-user@lists.sourceforge.net> > Message-ID: <552d28a2.8040...@gmail.com> > 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
GetDataFromAnotherForm.tar.gz
Description: application/gzip
------------------------------------------------------------------------------ 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user