[Gambas-user] how to add have array of textbox (or other obje ct)?

Rob sourceforge-raindog2 at ...94...
Thu May 6 18:31:42 CEST 2004


On Thursday 06 May 2004 10:26, Premoli, Roberto [ITPPG/1010] 
wrote:
> They are array of texboxs, buttons and forms.
> I have to create them and place onto my form BEFORE run time.

One of my clients needed this too, and was slogging through the 
run time control creation thing when I discovered another 
technique (maybe Benoit suggested it to me, I can't remember...)

1. When placing your controls on the form at design time, set 
their Group property to the name of the array into which you 
plan to put them.  This will cause events to be handled by 
functions named Groupname_Eventname.

2. Then set their Tag property to what should be their index in 
the array.

3. Finally, at runtime, loop through the window's Children 
container looking for a nonzero tag, and add them to the array.

If you used multiple arrays in VB, you can add more stuff to the 
Tag property to differentiate.

I agree that it should be easier to create control arrays since 
they are so commonly used in business applications, but this 
workaround has saved us a lot of time and I hope to include it 
in the eventual Gambas version of the VB form converter I started 
and Nelson improved on.

Rob





More information about the User mailing list