[Gambas-user] control groups
Christopher Brian Jack
brian at ...1334...
Mon Dec 4 09:40:52 CET 2006
On Sun, 3 Dec 2006, Eldon Eller wrote:
> Yes, I know that control groups don't work with FOR EACH. What I am
> looking for is a way to do what FOR EACH would do if it did work. In
> short, to look at each control in the control group and determine its
> properties so I can take some action based on those properties. For
> example, if the control is a button and the button text is "foo" then
> change the foreground to red. Please forgive my inability to
> communicate, but please don't give up on me. Tnx, EEE
You could use a Variant[] array and fill it in with the Control handles
using a prepended Tag attribute to identify the group members (or the new
Object.Name functionality in 2.9.46a but its semantics may change so its
use is not recommended for Control groups). For this example set your
tags on controls in the group to be of the form group1_BlahBlahBlah for
each control in the group. Each tag can be more appropriately set but
keep the group1_ part in the tag for all Controls of the group.
In class defines:
'Yes the NEW is needed or you will get "Not An Object" errors
DIM Group1Controls AS NEW Variant[]
In Form_Open:
DIM hCtl AS Control
FOR EACH hCtl IN ME.Controls
'stick all controls matching the
'prepended group tag into Group1Controls
TRY IF INSTR(hCtl.Tag,"group1_")=0 THEN Group1Controls.Add(hCtl)
NEXT
Once that is done in an event handler the following would suffice:
DIM hCtl AS Control
FOR EACH hCtl in Group1Controls
'Check properties on each hCtl here
'and do as you were indicating
NEXT
If you have more than one group create and initialize additional Variant[]
arrays for each group you want to be able to iterate with using FOR EACH
in Form_Open.
.=================================================.
| Christopher BRIAN Jack aka "Gau of the Veldt" |
+================================================='
| oevna at ...1543...
`=================================================-
Hi Spambots, my email address is sputnik at ...1334...
Hi Humans, my email address uses rot13 cipher
More information about the User
mailing list