begin process at 2010 02 10 16:07:01
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive Visual Basic & VB.NET

 > 

Archives Visual Basic

 > 

J'AI BESOIN D'AIDE !!!! :)

 > 

evenement click


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

evenement click

vendredi 28 novembre 2003 à 11:19:50 | evenement click

whiskygt

Salut
Je voudrai savoir si il est possible de creer un evenement click sur un label creer dynamiquement ??
Si oui comment ?
merci
vendredi 28 novembre 2003 à 11:55:20 | Re : evenement click

BruNews

Administrateur CodeS-SourceS
Se recupere par son index.
J'ai deja vu le sujet traite de nombreuses fois en sources ou dans forum.
BruNews, ciao...
vendredi 28 novembre 2003 à 12:06:08 | Re : evenement click

BasicInstinct

Membre Club
je sais pas, mais ca marche en passant pas des classes :

creer une classe Cls_Label



Option Explicit

Private WithEvents oLed As VB.Label
'on peut recréer les évènements du composant
Public Event Click()

Public Sub Create(oForm As Form, sKey As String)
Set oLed = oForm.Controls.Add("VB.label", sKey)
End Sub

Private Sub Class_Terminate()
Set oLed = Nothing
End Sub

Private Sub oLed_Click()
'ICI LE CODE DU CLICK

RaiseEvent Click 'lie l'événement vb.Label_Click à Label_Click
End Sub



'Il faut recréer les propriété et méthode du composant
'=====================================================
Public Property Let Top(sNewValue As Single)
oLed.Top = sNewValue
End Property

Public Property Get Top() As Single
Top = oLed.Top
End Property

Public Property Let Left(sNewValue As Single)
oLed.Left = sNewValue
End Property

Public Property Get Left() As Single
Left = oLed.Left
End Property

Public Property Let Height(sNewValue As Single)
oLed.Height = sNewValue
End Property

Public Property Get Height() As Single
Height = oLed.Height
End Property

Public Property Let Width(sNewValue As Single)
oLed.Width = sNewValue
End Property

Public Property Get Width() As Single
Width = oLed.Width
End Property

Public Property Let BorderStyle(iNewValue As Integer)
oLed.BorderStyle = iNewValue
End Property

Public Property Get BorderStyle() As Integer
BorderStyle = oLed.BorderStyle
End Property

Public Property Let Visible(bNewValue As Boolean)
oLed.Visible = bNewValue
End Property

Public Property Get Visible() As Boolean
Visible = oLed.Visible
End Property

Public Property Let BackColor(lNewValue As Long)
oLed.BackColor = lNewValue
End Property

Public Property Get BackColor() As Long
BackColor = oLed.BackColor
End Property


Public Property Let Appearance(lNewValue As Long)
oLed.Appearance = lNewValue
End Property

Public Property Get Appearance() As Long
Appearance = oLed.Appearance
End Property

Public Property Let Caption(lNewValue As String)
oLed.Caption = lNewValue
End Property

Public Property Get Caption() As String
Caption = oLed.Caption
End Property

Public Property Let Alignment(lNewValue As Long)
oLed.Alignment = lNewValue
End Property

Public Property Get Alignment() As Long
Alignment = oLed.Alignment
End Property

Public Property Let Bold(lNewValue As Boolean)
oLed.Font.Bold = lNewValue
End Property

Public Property Get Bold() As Boolean
Bold = oLed.Font.Bold
End Property

Public Property Let Tag(lNewValue As Boolean)
oLed.Tag = lNewValue
End Property

Public Property Get Tag() As Boolean
Tag = oLed.Tag
End Property



puis creer une classe cls_labels



Option Explicit

Private cCol As Collection

Public Function Add(oForm As Form, sKey As String) As Cls_Label
Dim oLed As New Cls_Label

oLed.Create oForm, sKey
cCol.Add oLed
'renvoyer l'objet créé
Set Add = oLed
End Function

Public Property Get Item(vIndexKey As Variant) As Cls_Label
'vIndexKey contient l'index ou la clé dans la collection
Set Item = cCol(vIndexKey)
End Property

Public Property Get Count() As Long
Count = cCol.Count
End Property

Public Sub Remove(vIndexKey As Variant)
'vIndexKey contient l'index ou la clé, il est donc
cCol.Remove vIndexKey
End Sub

Public Property Get NewEnum() As IUnknown
'permet d'énumérer la collection avec la syntaxe For...Each
Set NewEnum = cCol.[_NewEnum]
End Property

Private Sub Class_Initialize()
Set cCol = New Collection
End Sub

Private Sub Class_Terminate()
Set cCol = Nothing
End Sub




et apres s'utilise comme ca :



For I = 0 To 10
Set oLed = cLeds.Add("Label" & I) ' création du contrôle avec un nom unique
oLed.Caption = I
'paramétrage du contrôle créé
oLed.Top = 1400 + (I - 1) * 480

oLed.Height = 495
oLed.Width = 495
oLed.BorderStyle = 1
oLed.Visible = True
oLed.BackColor = vbWhite
oLed.Appearance = 0
oLed.Alignment = 2
oLed.Tag = 0
Next I



Bon courage

@++




BasicInstinct


Cette discussion est classée dans : creer, click, evenement


Répondre à ce message

Sujets en rapport avec ce message

comment creer un evenement click sur un controle creer ds le code ? [ par horko ] voila, la question est dans le sujet, y a rien d autre a rajouter. Peut etre qu il faut que je vous dise ce que je veux faire.Je cherche a recuperer u creer un evenement click sur un noeud d'un TreeView [ par chico79 ] bonjourj'aimerais savoir comment on fais pour créer une action lorsd'un click sur un noeud d'une treeviewessayant treeview_dblClick() ... ça declenche comment creer un evenement? [ par bidules ] j'aurais voulu savoir comment faire pour creer ses propres evenements.Tout ce que je sais c qu'ils se declare sous la forme PUBLIC EVENT NomDeLeveneme evenement click sur un datagrid [ par novarno ] Bonjourje voudrais recuperer l'evenement de click sur une case d'un datagrid avec la ligne et la colonne de la case clickéje n'arrive meme pas à recup evenement [ par fagol ] salutJe voudrai eviter le declanchement :de Private Sub CheckBox6_Click, lorsque j'execute : sub toto.Voir exemple.lorsque je modifie l'etat de checkb Evenement pour chaque index [ par comtention ] Bonjour j'aimerais savoir si il est possible davoir un evenement click (par exemple) pour chaque index d'un bouton?donc un truc du style, mais sa marc creer un evenement (vb.net) [ par sgrant ] Bonjourg créé un objet herité du control Label, g ajouter à ce control la propriété suivante :Valeur stringcomment declencher un evenement lorque "Val evenement click dans cellule table [ par jojo68 ] Bonjour à tous,J'avais posté ce meme message il y a quelque temps...J'ai un formulaire dans access directement lié à une table.Est il possible de défi Evenement click d'une cellule dans Excel [ par fred.toto ] Bonjour à tous, je voudrais juste savoir si quelqu'un sait comment récupérer l'évenement click d'une cellule excel?Merci d'avance Fred Creer Evenement .NET [ par chris81 ] bonjour,je cherche comment creer un evenement qui n'existe pas sur un objet et lui rattacher l'evenement.Par exemple, j'ai un textbox et je veux assoc


Nos sponsors


Sondage...

Comparez les prix


HTC Hero

Entre 550€ et 550€

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,995 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales