put pixel

  • Thread starter Thread starter Bulba008
  • Start date Start date
B

Bulba008

How to put pixel or draw line in VB.NET?

Please short example.

B.
 
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
 
* "Jay B. Harlow said:
Did you mean:

pen.Dispose()

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

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

ACK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top