[Gambas-user] how to write text in indexed list of labels

Jussi Lahtinen jussi.lahtinen at gmail.com
Mon Sep 7 22:24:12 CEST 2020


> BTW It is wonderful that this is so! As it enables us to write hundreds
> of custom controls which may have any number of weird properties unknown
> to Me[controlname As String]
>

Me[] is just collection of objects (specifically controls). It does not
"know" anything and it doesn't have to.
It just returns the object, which does or does not have the asked property.

I just find the cast really confusing:

Dim obj As Object = Me["Label1"]

Print Object.Type(obj) = Object.Type(Me["Label1"])
True

Print obj = Me["Label1"]
True

Yet, obj is an instance of label and Me["Label1"] is an instance of
control. Object.type() just cannot show it.
But everything works OK if you trick Gambas to do the cast, example both
work:

["a": Me["Label1"]]["a"].Text = "Pippo"

[Me["Label1"], "a"][0].Text = "Pippo"


Jussi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20200907/9d919296/attachment-0001.htm>


More information about the User mailing list