Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Foreign Languages > French Forum
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

créer un bouton dynamiquement et ajouter un "event Name"

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-04-2011, 04:15 PM
logemag's Avatar
Junior Member
 
Join Date: Dec 2011
Posts: 24
Default créer un bouton dynamiquement et ajouter un "event Name"

Bonjour, sur mon projet, je dois créer des boutons dynamiquement, en les indexant, mais je ne sais pas comment donner un évènement à ce bouton indéxé, comment je dois faire comprendre que l'événement click sur n'importe lequel de ces boutons créera une action ?

Je sais pas trop si j'ai été clair : peut être un bout de code aidera mieux :

Code:
Sub Activity_Create(FirstTime As Boolean)
'demarre la page graphique
activity.LoadLayout ("designGRID")
'd�finit la longueur et largeur du bouton
Dim xPAN As Int : xPAN = panel1.Width / 4
Dim yPAN As Int : yPAN = panel1.Height / 5

' la boucle d'affichage des boutons en grille 4 x 5
Dim btnGRILLE(20As Button
Dim index As Int : index = 0
For a = 0 To 3
    
For b = 0 To 4
        btnGRILLE(index).Initialize (
"btnGRILLE")
        panel1.AddView(btnGRILLE(index), xPAN * a, yPAN * b , xPAN, yPAN)
        btnGRILLE(index).Text = index 
' �a sera remplac� par les �l�ments d'une liste
        btnGRILLE(index).Tag = index 
        index = index+
1
    
Next
Next
end sub
comment je définis un _click sur mon btnGRILLE(index) ?
ou comment ajouter un "Event name" à la création pour avoir un sender ?
(Débutant B4A, je regrette déjà les index de VB6 !)
Reply With Quote
  #2 (permalink)  
Old 12-04-2011, 04:40 PM
logemag's Avatar
Junior Member
 
Join Date: Dec 2011
Posts: 24
Default

pardon j'ai du trop réfléchir, mon Event Name est le Initialize, donc après c'est tout bête avec un sender :

Code:
Sub btnGRILLE_Click
Dim btnSELECT As Button 
    btnSELECT = 
Sender
    label1.Text = btnSELECT.tag
End Sub
désolé pour ce post...

Remarquez quand on vient de VB, ça change vraiment, et c'est peut être pas inutile comme petit exemple.
Reply With Quote
  #3 (permalink)  
Old 12-04-2011, 06:23 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

L'exemple existe, peut être un peu caché, dans le Beginner's Guide chapitre 3 Second Program.

Meilleures salutations.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Form.Load event" (?) mjcoon Questions (Windows Mobile) 4 09-27-2009 08:55 PM
Catching the "Shift", "right" & "left" keys linum Questions (Windows Mobile) 3 08-21-2009 01:22 PM
calling the device's "Programs" or "settings" screens karmba_a Questions (Windows Mobile) 3 03-15-2009 05:41 PM
Possibility of "Close event" of DataTimePicker mozaharul Questions (Windows Mobile) 2 10-15-2008 06:06 AM
calling the device's "Programs" or "settings" screens HarleyM Questions (Windows Mobile) 0 12-05-2007 02:59 AM


All times are GMT. The time now is 06:00 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0