Questo:
codice:
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
NON E' l'evento click del pulsante. Questo invece sì:
codice:
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
Variabile globale:
codice:
Public Colore As Color = Color.Blue
Evento click:
codice:
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
Colore = Color.Red
End Sub
Evento paint:
codice:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.FillRectangle(New SolidBrush(Colore), New RectangleF(100, 100, 100, 100))
End Sub