[Gambas-user] event handling for member of a collection
Bodard Fabien
gambasfr at ...11...
Thu Nov 4 23:30:22 CET 2004
Le jeudi 4 Novembre 2004 22:44, LACKKD at ...674... a écrit :
> If I have:
>
> Dim colToolBtns AS Collection
> Dim tBtn AS ToolButton
> Dim i AS Integer
>
> For i = 0 To 10
> tBtn = new TollButton(frmMain)
// tBtn = new ToolButton(frmMain) --> workbetter with no spelling fault
tBtn = new ToolButton(frmMain) as "myButton"
>
> colToolBtns.Add(tBtn, i)
> Next
>
>
> How can I now access the click() event of the buttons in the collection?
>
> Thanks,
> Kevin
Then add a sub like this :
PUBLIC SUB MyButton_Click()
END
and use the LAST keyword to manage each button. I think it can be usefful to
add a virtual index in the tag property of each button.
Dim colToolBtns AS Collection
Dim tBtn AS ToolButton
Dim i AS Integer
For i = 0 To 10
tBtn = new ToolButton(frmMain) as "myButton"
tBtn.Tag = i
colToolBtns.Add(tBtn, i)
Next
END
PUBLIC SUB MyButton_Click()
SELECT CASE LAST.Tag
CASE 1
do something
CASE 2
do something else
CASE ELSE
END SELECT
END
Fabien BODARD
More information about the User
mailing list