I have previously created buttons in my code, as shown:
Dim Itm As New Button
Itm.Name = "Itm" & i
Itm.Height = 62
Itm.Width = 159
Itm.Text = Temp(i, 0).ToUpper
Itm.Left = (F * 165)
Itm.Visible = True
Itm.BackColor = Colour
Itm.ForeColor = Color.Black
Me.pnlItemButton1.Controls.Add(Itm)
When I run the form, the buttons are created but I now need to create an Event Sub for when the new buttons are clicked. I have tried this:
Private Sub Itm1_click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Itm1.click
End Sub
But get an error that 'handle clause requires with WithEvent'
So how can i do this ?
Also, the amount of buttons - Itm(i) is variable, so how can i create a handle that will account for Itm1 to Itm99?