put pixel

  • Thread starter Thread starter Bulba008
  • Start date Start date
On which control you want to paint?

Following code will draw a line on a form, by hooking up to the paint event:
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint
Dim g As Graphics = e.Graphics()
Dim pen As New Pen(Color.Black)
pen.Width = 3
g.DrawLine(pen, 1, 10, Me.Width, 10)
End Sub
 
* "Jan Tielens said:
Following code will draw a line on a form, by hooking up to the paint event:
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint
Dim g As Graphics = e.Graphics()
Dim pen As New Pen(Color.Black)
pen.Width = 3
g.DrawLine(pen, 1, 10, Me.Width, 10)
\\\
p.Dispose()
///

End Sub
 
Herfried,
Did you mean:

pen.Dispose()

As there are no p variables in Jan's example.

You don't want to dispose the Graphics variables as this is the Paint event.

Hope this helps
Jay
 
Back
Top