1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 5
Dim bt As New Button
bt.Name = "bouton" & i.ToString
bt.Text = "Bouton n° " & i.ToString
Me.Controls.Add(bt)
bt.Location = New Point(20, 10 + 25 * i)
bt.Visible = True
AddHandler bt.Click, AddressOf MesBoutons_Click
Next
End Sub
Private Sub MesBoutons_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show(String.Format("Tu as cliqué sur le bouton {0}", DirectCast(sender, Button).Name))
End Sub |
Partager