0

I'm new at this.

How come this doesn't work...

Private Sub ColorKeyForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        'Draws diagonal line of dot and dash on form
        Dim objGraphics As Graphics = Me.CreateGraphics
        Dim objPen As Pen
        objPen = New Pen(Drawing.Color.DarkBlue, 3)
        objPen.DashStyle = Drawing2D.DashStyle.DashDot
        objGraphics.DrawLine(objPen, 20, 20, 400, 400)

  
        'Next routine does nothing
        Dim objPicGraphics As Graphics = picColorKey.CreateGraphics
        objPen = New Pen(Drawing.Color.Chartreuse, 5)
        objPen.DashStyle = Drawing2D.DashStyle.Dot
        objPicGraphics.DrawLine(objPen, 20, 20, 400, 400)

    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.

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by OldQBasicer
1

Handle paint event of picColorKey,

Private Sub picColorKey_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        Dim objPen As Pen
        Dim objPicGraphics As Graphics = e.Graphics

        objPen = New Pen(Drawing.Color.Red, 5)
        objPen.DashStyle = Drawing2D.DashStyle.Solid
        objPicGraphics.DrawLine(objPen, 20, 20, 400, 400)
    End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.