Results 1 to 9 of 9

Thread: x-y axis

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    4

    x-y axis

    I have to draw a x- and y-axis in a picturebox, and I have no idea how to get started

  2. #2
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: x-y axis

    Sorry your going to have to clarify the question are you drawing a graph?

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: x-y axis

    Take a look at the Paint event.
    You'll see that the Paint eventhandler provides this parameter:
    VB.NET Code:
    1. e As System.Windows.Forms.PaintEventArgs
    Take a look at the different members of this 'e' object. You'll find that its very straight forward to draw anything on the PictureBox.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    4

    Re: x-y axis

    yes
    like this: y = ax² + bx + c

  5. #5
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: x-y axis

    Put a picturebox on a form and a textbox

    make the form and the picture box color black

    Code:
        Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            If e.KeyCode = Keys.Right Then
                Dim g As Graphics = Me.PictureBox1.CreateGraphics
                Dim p As Pen = New Pen(Color.White, 1)
                Dim sStart As Point = New Point(0, 0)
                Dim eEnd As Point = New Point(CInt(Me.TextBox1.Text), 0)
                g.DrawLine(p, sStart, eEnd)
            End If
        End Sub
    then hit the right arrow key

    forgot that bit
    Last edited by toecutter; Mar 26th, 2008 at 07:02 AM.

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: x-y axis

    Dont create the graphics object like that. Use the Paint event.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  7. #7
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: x-y axis

    You could just make a graph using excel and import it into your project as a picture.

  8. #8
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: x-y axis

    Quote Originally Posted by Atheist
    Dont create the graphics object like that. Use the Paint event.
    Will it still work using the TextBox1_KeyDown event?

  9. #9
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: x-y axis

    Quote Originally Posted by toecutter
    Will it still work using the TextBox1_KeyDown event?
    Yes. You'd call the PictureBox' Refresh or Invalidate+Update methods in the KeyDown eventhandler.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

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