Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For i As Integer = 1 To 5 Dim b As New Button b.Name = "Bouton" & i.ToString b.Text = i.ToString Me.Controls.Add(b) b.Location = New Point(10, 10 + 25 * i) AddHandler b.Click, AddressOf QuelBouton_Click Next End Sub Private Sub QuelBouton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) MessageBox.Show(String.Format("Le controle {0} qui a été cliqué", CType(sender, Button).Name)) End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question