Buongiorno.
Ho un'array di 5 bottoni creato a runtime al quale ho aggiunto l'handler click e fin qui tutto ok.
Se clicco su un pulsante riesco a fare quello che devo.
Ma se per esempio avessi il numero del bottone da premere in una variabile come posso invocare l'evento click ?
Creo i bottoni in una tableLayout panel 1 Col x 5 Row
codice:
For i As Integer = 0 To btnCamsArr.Length - 1
btnCamsArr(i) = New System.Windows.Forms.Button
btnCamsArr(i).TextAlign = ContentAlignment.MiddleCenter
btnCamsArr(i).Text = CStr(i + 1)
btnCamsArr(i).Font = New System.Drawing.Font(btnInBArr(i).Font, FontStyle.Bold)
btnCamsArr(i).BackColor = Color.DimGray
btnCamsArr(i).Name = CStr("btnCam" & i)
tblCams.Controls.Add(btnCamsArr(i), i Mod CamsRow, i \ CamsCol)
AddHandler btnCamsArr(i).Click, AddressOf btnCamsClick
Next
L'evento click
codice:
Public Sub btnCamsClick(ByVal sender As Object, ByVal e As System.EventArgs)
For i As Integer = 0 To btnCamsArr.Length - 1
If btnCamsArr(i) Is sender Then
btnCamsArr(i).BackColor = Color.Red
CurrentCamSelect = i
Else
btnCamsArr(i).BackColor = Color.DimGray
End If
Next
Call ReadIni()
End Sub
Come faccio a simulare il click avendo in una variabile un valore compreso tra i bottoni creti ?
call btnCamsClick(?,?)
Grazie, Alberto