I have to draw a x- and y-axis in a picturebox, and I have no idea how to get started :confused:
Printable View
I have to draw a x- and y-axis in a picturebox, and I have no idea how to get started :confused:
Sorry your going to have to clarify the question are you drawing a graph?
Take a look at the Paint event.
You'll see that the Paint eventhandler provides this parameter:
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.VB.NET Code:
e As System.Windows.Forms.PaintEventArgs
yes
like this: y = ax² + bx + c
Put a picturebox on a form and a textbox
make the form and the picture box color black
then hit the right arrow keyCode: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
forgot that bit :)
Dont create the graphics object like that. Use the Paint event.
You could just make a graph using excel and import it into your project as a picture.
Will it still work using the TextBox1_KeyDown event?Quote:
Originally Posted by Atheist
Yes. You'd call the PictureBox' Refresh or Invalidate+Update methods in the KeyDown eventhandler.Quote:
Originally Posted by toecutter