[Gambas-user] Re ferencing existing multiple controls in loops

Richard Muir-Gladman richard at ...2079...
Mon Mar 30 23:21:42 CEST 2009


On Mon, 2009-03-30 at 13:55 -0700, jbskaggs wrote:
> Okay I have a form with say 50 picturebox controls:
> 
> How does one check each controls in a loop?
> 
> So if I wanted to have a big picture box reference each of the previous
> pictureboxes
> 
> 
> In GML I could use this:
> 
> a="PictureBox"
> for i = 0 to 50 step 1
> b=a&i
> BigPicturebox.Picture=b.picture
> wait 2
> next i
> 
> But In gambas I cannot reference a control with a string.  I have tried
> dozens of ways and spent eleven hours reading the docs, looking at examples,
> and so on.  But the solution eludes me.
> 
> It seems really inefficient to type out
> 
> Bigpicturebox.picture=picturebox1.picture
> wait 2.0
> Bigpicturebox.picture=picturebox2.picture
> wait 2.0
> Bigpicturebox.picture=picturebox3.picture
> wait 2.0
> Bigpicturebox.picture=picturebox4.picture
> wait 2.0
> 
> etc... fifty times
> 
> I am using pictureboxes but it could be any existing control I would want to
> control from another event.

One way would be to put them in a container and access the children
array

    FOR i = myContainer.Children.Count - 1 TO 0 STEP -1
        myContainer.Children[i].DoWhatEver()
    NEXT 

-- 
Quantum materiae materietur marmota monax si marmota monax materiam
possit materiari?
(How much wood would a woodchuck chuck if a woodchuck could chuck wood?)

Registered Linux User: #459086





More information about the User mailing list