943,076 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3756
  • VB.NET RSS
Feb 8th, 2010
0

Can't Draw Line in Picture Box

Expand Post »
I'm new at this.

How come this doesn't work...

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub ColorKeyForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
  2. 'Draws diagonal line of dot and dash on form
  3. Dim objGraphics As Graphics = Me.CreateGraphics
  4. Dim objPen As Pen
  5. objPen = New Pen(Drawing.Color.DarkBlue, 3)
  6. objPen.DashStyle = Drawing2D.DashStyle.DashDot
  7. objGraphics.DrawLine(objPen, 20, 20, 400, 400)
  8.  
  9.  
  10. 'Next routine does nothing
  11. Dim objPicGraphics As Graphics = picColorKey.CreateGraphics
  12. objPen = New Pen(Drawing.Color.Chartreuse, 5)
  13. objPen.DashStyle = Drawing2D.DashStyle.Dot
  14. objPicGraphics.DrawLine(objPen, 20, 20, 400, 400)
  15.  
  16. End Sub

... the top part draws a line on the form but the second part does nothing. The picColorKey is a picture box on the form.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
OldQBasicer is offline Offline
38 posts
since Oct 2009
Feb 8th, 2010
1
Re: Can't Draw Line in Picture Box
Handle paint event of picColorKey,
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub picColorKey_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
  2. Dim objPen As Pen
  3. Dim objPicGraphics As Graphics = e.Graphics
  4.  
  5. objPen = New Pen(Drawing.Color.Red, 5)
  6. objPen.DashStyle = Drawing2D.DashStyle.Solid
  7. objPicGraphics.DrawLine(objPen, 20, 20, 400, 400)
  8. End Sub
Moderator
Reputation Points: 2134
Solved Threads: 1227
Posting Genius
adatapost is offline Offline
6,524 posts
since Oct 2008
Feb 9th, 2010
0
Re: Can't Draw Line in Picture Box
Thanks, that worked!
Reputation Points: 10
Solved Threads: 0
Light Poster
OldQBasicer is offline Offline
38 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Problem using referenced DLL
Next Thread in VB.NET Forum Timeline: pls i need help on project topics





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC