注册 登录
编程论坛 VB.NET论坛

[求助]在picturebox控件上画函数图像

点奈特 发布于 2009-12-01 15:01, 1476 次点击
如题,在picturebox1控件上画函数图像(比如y=x^2+3*x),单击button1时,开始画图像.
单击button2时,picturebox1上的图像清除。
十分感谢各位给与解答。
1 回复
#2
不说也罢2009-12-02 19:54
程序代码:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myPen As Graphics = PictureBox1.CreateGraphics
        Dim x1 As Single, y1 As Single, x As Single, y As Single, r As Single, width As Single, height As Single
        r = 1
        For x1 = 1 To 20
            y1 = 6 * x1 - 3
            width = r * 20
            height = r * 20
            x = x1 - width / 1
            y = y1 - height / 1000
            myPen.FillEllipse(Brushes.Red, x, y, width, height)
        Next
        '上面是一个例子,自己琢磨如何绘图吧
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        PictureBox1.Image = Nothing '清除已绘制或加载的图像
    End Sub
End Class
1