[Gambas-devel] Gambas Question
Benoit Minisini
gambas at ...1...
Wed Mar 29 22:06:46 CEST 2006
On Wednesday 29 March 2006 20:02, Scott, Vince wrote:
> In VB I could use Control arrays which made it easy to loop through the
> controls setting or clearing values. VB.net has done away with them,
> RealBasic doesn't use them and Gambas doesn't support them either. I find
> this odd as I found control array to be an awesome part of VB and used them
> all the time. Is there some underlying reason they are not being used??
>
> In Gambas is there away to cycle through a group of controls??
>
> For example in VB I could do this with a control:
>
> For X = 0 to Count
>
> txtMyTextBox(X).Text = X
>
> Next
>
> Is this the only choice I have now:??
>
> txtMyTextBox1.Text = 0
> txtMyTextBox2.Text = 1
> txtMyTextBox3.Text = 2
> ...
>
>
> Thanks,
> Vince
>
You have many solutions in Gambas. It depends on what you need exactly:
1) If you need to manage the events of many controls with the same event
handlers, use the control '(Group)' property in the IDE, or give the same
event name to all your controls if you create them by hand.
2) You can put all the controls you need in an Object[] array. This way the VB
control arrays come back.
3) If all your controls are in the same container, you can enumerate the
Children property of this container.
4) You can use the Tag property. In Gambas, the Tag can be what you want, not
just a string.
5) You can use inheritance and/or composition with the native control classes.
I can't tell you precisely, as I don't know what you do exactly.
Regards,
--
Benoit Minisini
More information about the Devel
mailing list