First, put the buttons in a group that can catch events:
       ButtonArray[X] = NEW Button(ME) as "Buttons"

Then, give every button an individual Tag:
        .height = 20
        .Tag = X

And the event to see which one is clicked:
Public Sub Buttons_Click()      ' reacts to all the buttons
  Dim i As Integer

  i = Last.Tag  'reads the Tag, so you see which one it was
  Print i

  Select Case
  .....
  End Select
End



Am 11.02.2011 17:00, schrieb Stephen Bungay:
>    Given the following code (Gambas 2.22)
> 
> PUBLIC SUB Form_Open()
>    DIM X AS Integer
>    DIM ButtonArray[10] AS Object
> 
>    FOR X = 0 TO 9
>        ButtonArray[X] = NEW Button(ME)
>        WITH ButtonArray[X]
>             .X = 90 + (20 * x)
>             .Y = 100
>             .Width = 20
>             .height = 20
>        END WITH
>    NEXT
> 
> END
> 
> 
>    How then would one trap the events being raised by a click on one of 
> the buttons in ButtonArray[]?
> 
>    I'm assuming (a bad thing... I know) that the array 'ButtonArray' 
> persists after Form_Open completes and until the form is closed.
> 
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to