[Gambas-user] declaring control groups at runtime
Doriano Blengino
doriano.blengino at ...1909...
Wed Sep 9 13:03:33 CEST 2009
Matteo Pasotti ha scritto:
> Hi,
> I'm writing an application that once read a configuration file, it
> creates at runtime some buttons.
> My problem is represented by the declaration of a unique event for all
> these buttons with the target of recognizing the caller and change some
> of its properties.
> I think it's similar to the Group property but I'm not able of use it at
> runtime :-(
> Someone has any idea on what can I do?
>
Create every button with an event handler associated like this:
btAbutton = new Button(me) as "Button1" ' first button
btAbutton2 = new Button(me) as "Button1" ' another button
btAbutton2.tag = 5
The event handler for click will be:
sub Button1_Click()
if LAST=btAbutton ...
if LAST=btAButton2...
if LAST.tag=5 then... ' the same as before
So you can:
1. Create buttons, and keep the variable around
2. Create buttons without keep variables around, but setting
different TAG properties
3. Noye that you can use other fields other than Tag (for example, Text)
4. You can group all the buttons in the same event handler, as
before, or you can use more than one handler
Quick response - I hope it is clear. If not, let us know.
Regards,
Doriano
More information about the User
mailing list