Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim g As Graphics
Dim pen1, pen2 As Pen Dim brush1, brush2 As Brush
'g = Button1.CreateGraphics 'buttom1上に描画する時
g = Me.CreateGraphics 'form上に描画する時
pen1 = New Pen(Color.Red) pen2 = New Pen(Color.Blue, 3) pen2.DashStyle = Drawing2D.DashStyle.Dash
brush1 = New SolidBrush(Color.Purple) brush2 = New Drawing2D.HatchBrush(Drawing2D.HatchStyle.Cross, Color.Red, Color.White) If i = 0 Then brush1 = New SolidBrush(Color.Red) g.FillRectangle(brush1, 10, 120, 100, 50) i = 1 ElseIf i = 1 Then brush1 = New SolidBrush(Color.SeaGreen) g.FillRectangle(brush1, 10, 120, 100, 50) i = 2 ElseIf i = 2 Then brush1 = New SolidBrush(Color.Purple) g.FillRectangle(brush1, 10, 120, 100, 50) i = 0
End If 'g.DrawLine(pen1, 10, 10, 250, 40) 'g.DrawRectangle(pen1, 10, 50, 100, 50)