[Gambas-user] Get the object of a component by name.
Tobias Boege
taboege at ...626...
Wed Feb 24 01:00:02 CET 2016
On Tue, 23 Feb 2016, Matias De lellis wrote:
> > So, what I read out of your mail is that you have one object Firmata1 which
> > has a certain configuration. You now want to add controls dynamically to the
> > Form which should inherit Firmata1's configuration by obtaining a reference
> > to the Firmata1 object.
>
>
> Not completely dynamic.. After completing write the controls the idea is just change the list of properties of the controls placed on the form. (Not writing a single line of code more after design forms)
>
> > 2. Can't you pass the Firmata1 object to the constructors of the controls?
>
> Would be ideal, but I do not see how. Justly my idea was to add a property representing the instance name, and get the instance itself from that. http://gambaswiki.org/wiki/comp/gb/class/instance seems ideal but not work here..
>
Class["Name"].Instance returns the auto-instance of an auto-creatable (i.e.
Create Static[0]) class. Unless you class is Create Static, this will not
give you any object at all.
> > 3. (A refinement of 2.) Make the Firmata class a Container object and
> > create the controls inside the container Firmata1. This way, the
> > controls can access their parent Firmata1 and its configuration
> > directly. This is how the DataSource control from gb.db.form works,
> > if you are familiar with that.
>
>
> I will investigate this option..
>
If you don't need to create controls at runtime, i.e. the layout of your
form is complete at compile time, then this would be the way to go. I attach
a small project which shows how it's done.
Regards,
Tobi
[0] http://gambaswiki.org/wiki/lang/createstatic
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: container-config-0.0.1.tar.gz
Type: application/octet-stream
Size: 12398 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20160224/af2e98f9/attachment.obj>
More information about the User
mailing list