Results 1 to 1 of 1

Thread: Form Draw Demo

  1. #1

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Form Draw Demo

    An example on how to draw onto a form. I used iteration to draw a grid and a grid of circles to the form. Comment out different loops for different draw styles. You can download the attachment with the project for just paste the code into a blank form on a new project. Written with vb 2008 express.


    Code:
    Public Class Form1
    
        Private Sub Form1_Paint(ByVal sender As Object, ByVal e _
        As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    
    
            'comment out different for/next loops to see different drawing methods
            Dim i As Integer = 0
            Dim y As Integer = 0
    
            Me.BackColor() = Color.Green
    
            'iteration to draw horizontal lines
            For i = 0 To Me.Height Step 10
                e.Graphics.DrawLine(Pens.Red, 0, i, Me.Width, i)
            Next i
    
            'iteration to draw vertical lines
            For i = 1 To Me.Width Step 10
                e.Graphics.DrawLine(Pens.Red, i, 0, i, Me.Height)
            Next i
    
            'iteration to draw ellipses
            For y = 0 To Me.Height Step 10
                For i = 1 To Me.Width Step 10
                    e.Graphics.DrawEllipse(Pens.Blue, i, y, 10, 10)
                Next i
            Next y
    
        End Sub
    
    End Class
    Attached Files Attached Files
    Last edited by Brian M.; Jul 10th, 2008 at 02:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width