[Gambas-user] Gambas Help - PLEASE - Object Arrays - Need help ASAP

Rob sourceforge-raindog2 at ...94...
Thu Nov 6 14:42:45 CET 2008


On Thursday 06 November 2008 07:19, Robert Moss wrote:
> Ok, awesome. But what is a control group and how do I use one? I can't
> find any documentation on it

The "control group" concept in the form designer corresponds to what comes 
after the "AS" when you programmatically create a control.  In the example 
you posted, you're creating a control group.

Control groups don't automatically create an array when creating them in 
the form designer, or allow you to iterate through the controls; it just 
ensures that all the controls in the group trigger the same events.  But 
you're already creating an array in your code, so you've gotten that part 
licked.  

Differentiating between the controls when their event gets fired is where 
most people get tripped up.  Most people use the Tag property of each 
control to identify it, like this:

' in Form_Open
btns[0].tag = 0
btns[1].tag = 1

' in btns_Click
dim btnindex as integer
btnindex = LAST.Tag
Message.Info("You pressed button " & btnindex)

I find this usage clunky as well, but I've also run into situations where I 
wanted multiple controls of different types to trigger the same event, and 
control groups allowed me to do that where VB control arrays wouldn't 
have.

Rob




More information about the User mailing list