Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

comment reagir au clic de la souri quand on cree un tableau de lab

1 réponse
Avatar
benoit g
Public lbl_input(255) As Label


apres je dispose mes label

voici le code que j'utilise pour disposer mes ( label)selon le nombre voulu
et je voudrai pouvoir reagir au clic souri

Private Sub creat_template(ByVal nombre_input As Int16)


'Dim a As Integer
Dim x_pos As Integer
Dim y_pos As Integer
Dim x_index As Integer
Dim y_offset As Integer
y_offset = 40

x_pos = 0
y_pos = y_offset
For x As Integer = 0 To 255

lbl_input(x) = New Label

'Me.Controls.Add(lbl_input(x))
Next

For x As Integer = 0 To nombre_input '255
'lbl_input(x) = New Label
lbl_input(x).Location = New Point(x_pos + x, y_pos + x)
Me.Controls.Add(lbl_input(x))
'lbl_input(x).Refresh()
Next

'If nombre_input > 0 And nombre_input < 255 Then

x_index = 1
If nombre_input > 127 And nombre_input < 251 Then

For a As Integer = 1 To nombre_input

'lbl_input(a).Font.Size = 12
'lbl_input(a).Font.Bold = True
lbl_input(a).BorderStyle = BorderStyle.Fixed3D
lbl_input(a).BackColor = Color.DarkGray
'lbl_input(a).Left = 100
lbl_input(a).Height = 35
lbl_input(a).Width = 100
lbl_input(a).Location = New Point((x_index * 100) + x_pos,
y_pos)
lbl_input(a).Text = mafeuille3.str_input(a)
'lbl_input(a).Text = Str(a) + " "
x_index = x_index + 1


'Application.DoEvents()
lbl_input(a).Refresh()


If a = 10 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 1) + y_offset
End If
If a = 20 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 2) + y_offset
End If
If a = 30 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 3) + y_offset
End If
If a = 40 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 4) + y_offset
End If
If a = 50 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 5) + y_offset
End If
If a = 60 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 6) + y_offset
End If
If a = 70 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 7) + y_offset
End If
If a = 80 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 8) + y_offset
End If
If a = 90 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 9) + y_offset
End If
If a = 100 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 10) + y_offset
End If

If a = 110 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 11) + y_offset
End If
If a = 120 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 12) + y_offset
End If
If a = 130 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 13) + y_offset
End If
If a = 140 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 14) + y_offset
End If
If a = 150 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 15) + y_offset
End If
If a = 160 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 16) + y_offset
End If
If a = 170 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 17) + y_offset
End If
If a = 180 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 18) + y_offset
End If
If a = 190 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 19) + y_offset
End If
If a = 200 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 20) + y_offset
End If
If a = 210 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 21) + y_offset
End If
If a = 220 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 22) + y_offset
End If
If a = 230 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 23) + y_offset
End If
If a = 240 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 24) + y_offset
End If
Next a
' Me.Height = lbl_input(nombre_input - 1).Top + 2000
'dimentionne la forme 1
End If
If nombre_input > 0 And nombre_input < 128 Then
y_offset = 40

x_pos = 0
y_pos = y_offset


For a As Integer = 1 To nombre_input

'lbl_input(a).Font.Size = 12
'lbl_input(a).Font.Bold = True
lbl_input(a).BorderStyle = BorderStyle.Fixed3D
lbl_input(a).BackColor = Color.DarkGray
'lbl_input(a).Left = 100
lbl_input(a).Height = 70
lbl_input(a).Width = 100
lbl_input(a).Location = New Point((x_index * 100) + x_pos,
y_pos)
lbl_input(a).Text = mafeuille3.str_input(a)
x_index = x_index + 1


'Application.DoEvents()
'lbl_input(a).Refresh()


If a = 10 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 1) + y_offset
End If
If a = 20 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 2) + y_offset
End If
If a = 30 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 3) + y_offset
End If
If a = 40 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 4) + y_offset
End If
If a = 50 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 5) + y_offset
End If
If a = 60 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 6) + y_offset
End If
If a = 70 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 7) + y_offset
End If
If a = 80 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 8) + y_offset
End If
If a = 90 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 9) + y_offset
End If
If a = 100 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 10) + y_offset
End If

If a = 110 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 11) + y_offset
End If
If a = 120 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 12) + y_offset
End If

Next a
End If

End Sub

--
benoit

1 réponse

Avatar
S. B
Bonjour,

Il te faut utiliser la fonction AddHandler qui permet d'ajouter un handler
d'evenement à un objet, un truc dans le genre:

addhandle lblinput.click, addressof <tafonction>

il faut que le proto de ta fonction soit le même que celui du handler de
click standard du label.

ps.:
Sinon tu pourrais alléger ton code en positionnant ton contrôle de la façon
suivante:

xpos = 100* ( (a mod 10) + 1)
ypos = lbl_input(1).Height * (a 10)
lbl_input(a).Location = New Point( x_pos , y_pos )


En remplaçant 10 par une variable ca devrais meme te permettre de faire une
mise en forme variable en fonction du nombre de colonne que tu souhaites
utiliser, mais il te faudra sérieusement réorganiser ton code.

Bon courage,

"benoit g" a écrit dans le message de
news:
Public lbl_input(255) As Label


apres je dispose mes label

voici le code que j'utilise pour disposer mes ( label)selon le nombre
voulu
et je voudrai pouvoir reagir au clic souri

Private Sub creat_template(ByVal nombre_input As Int16)


'Dim a As Integer
Dim x_pos As Integer
Dim y_pos As Integer
Dim x_index As Integer
Dim y_offset As Integer
y_offset = 40

x_pos = 0
y_pos = y_offset
For x As Integer = 0 To 255

lbl_input(x) = New Label

'Me.Controls.Add(lbl_input(x))
Next

For x As Integer = 0 To nombre_input '255
'lbl_input(x) = New Label
lbl_input(x).Location = New Point(x_pos + x, y_pos + x)
Me.Controls.Add(lbl_input(x))
'lbl_input(x).Refresh()
Next

'If nombre_input > 0 And nombre_input < 255 Then

x_index = 1
If nombre_input > 127 And nombre_input < 251 Then

For a As Integer = 1 To nombre_input

'lbl_input(a).Font.Size = 12
'lbl_input(a).Font.Bold = True
lbl_input(a).BorderStyle = BorderStyle.Fixed3D
lbl_input(a).BackColor = Color.DarkGray
'lbl_input(a).Left = 100
lbl_input(a).Height = 35
lbl_input(a).Width = 100
lbl_input(a).Location = New Point((x_index * 100) + x_pos,
y_pos)
lbl_input(a).Text = mafeuille3.str_input(a)
'lbl_input(a).Text = Str(a) + " "
x_index = x_index + 1


'Application.DoEvents()
lbl_input(a).Refresh()


If a = 10 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 1) + y_offset
End If
If a = 20 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 2) + y_offset
End If
If a = 30 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 3) + y_offset
End If
If a = 40 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 4) + y_offset
End If
If a = 50 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 5) + y_offset
End If
If a = 60 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 6) + y_offset
End If
If a = 70 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 7) + y_offset
End If
If a = 80 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 8) + y_offset
End If
If a = 90 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 9) + y_offset
End If
If a = 100 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 10) + y_offset
End If

If a = 110 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 11) + y_offset
End If
If a = 120 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 12) + y_offset
End If
If a = 130 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 13) + y_offset
End If
If a = 140 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 14) + y_offset
End If
If a = 150 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 15) + y_offset
End If
If a = 160 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 16) + y_offset
End If
If a = 170 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 17) + y_offset
End If
If a = 180 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 18) + y_offset
End If
If a = 190 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 19) + y_offset
End If
If a = 200 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 20) + y_offset
End If
If a = 210 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 21) + y_offset
End If
If a = 220 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 22) + y_offset
End If
If a = 230 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 23) + y_offset
End If
If a = 240 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 24) + y_offset
End If
Next a
' Me.Height = lbl_input(nombre_input - 1).Top + 2000
'dimentionne la forme 1
End If
If nombre_input > 0 And nombre_input < 128 Then
y_offset = 40

x_pos = 0
y_pos = y_offset


For a As Integer = 1 To nombre_input

'lbl_input(a).Font.Size = 12
'lbl_input(a).Font.Bold = True
lbl_input(a).BorderStyle = BorderStyle.Fixed3D
lbl_input(a).BackColor = Color.DarkGray
'lbl_input(a).Left = 100
lbl_input(a).Height = 70
lbl_input(a).Width = 100
lbl_input(a).Location = New Point((x_index * 100) + x_pos,
y_pos)
lbl_input(a).Text = mafeuille3.str_input(a)
x_index = x_index + 1


'Application.DoEvents()
'lbl_input(a).Refresh()


If a = 10 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 1) + y_offset
End If
If a = 20 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 2) + y_offset
End If
If a = 30 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 3) + y_offset
End If
If a = 40 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 4) + y_offset
End If
If a = 50 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 5) + y_offset
End If
If a = 60 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 6) + y_offset
End If
If a = 70 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 7) + y_offset
End If
If a = 80 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 8) + y_offset
End If
If a = 90 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 9) + y_offset
End If
If a = 100 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 10) + y_offset
End If

If a = 110 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 11) + y_offset
End If
If a = 120 Then
x_index = 0
x_pos = 100
y_pos = (lbl_input(1).Height * 12) + y_offset
End If

Next a
End If

End Sub

--
benoit