十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
VB.net与VB不同。
成都创新互联公司专注于网站设计、成都网站建设、网页设计、网站制作、网站开发。公司秉持“客户至上,用心服务”的宗旨,从客户的利益和观点出发,让客户在网络营销中找到自己的驻足之地。尊重和关怀每一位客户,用严谨的态度对待客户,用专业的服务创造价值,成为客户值得信赖的朋友,为客户解除后顾之忧。
VB.net已经有专门绘图的类。
可以定义笔刷然后用Drawing类中的方法绘制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
。net 其实还是很好绘制图形的
你可以看下 Graphics 类
Dim d As New Bitmap(Me.Width, Me.Height) ‘一个图片吧
Dim g As Graphics = Graphics.FromImage(d)’绘制 准备在这个图片是进行
然后 就是你绘制的东西了
线 就是 g.DrawLine()
圆 弧度 就用 g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
复杂的就是 g.DrawBezier()
等 如果你用的是 VS的 编译 上面都有详细的参数说明
Dim d As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(d)
g.DrawArc(Pens.Black, New Rectangle(0, 0, 200, 200), 0, 360)
g.DrawLine(Pens.Red, New Point(0, 0), New Point(200, 200))
g.DrawLines(Pens.Green, New Point() {New Point(0, 0), New Point(50, 40), New Point(50, 80), New Point(90, 70), New Point(100, 400)})
g.DrawBezier(Pens.Yellow, New Point(0, 100), New Point(0, 0), New Point(200, 0), New Point(200, 200))
g.Dispose()
Me.BackgroundImage = d
1. 创建一个Graphics对象实例。
绘制图形必须创建Graphics对象。如果是在窗体上绘图,要使用下列代码创建Graphics对象;
Dim MyGraphics As Graphics = Me.CreateGraphics
如果是在PictrueBox里绘图,要使用下列代码创建Graphics对象;
Dim MyGraphics As Graphics = PictureBox1.CreateGraphics
2. 定义一个Brush对象,用来填充图形(如果你需要填充的话)。
如果填充封闭曲线或者多边形,必须创建Brush对象(或者Brush类的继承类对象),用来确定填充的颜色。例如下面的代码,创建了一个填充红色的画刷对象。在最后的括号里,用Color结构指定的枚举值,确定画刷的颜色。限于篇幅有关Color结构这里不展开,可能在后续博文里介绍。
Dim RedBrush As New SolidBrush(Color.Red)
你可以通过用VB.net控制excel,让excel生成曲线图,然后利用excelVBA将图输出,最后导入到VB.net就可以了。
拖一个PictureBox1控件
创建一个Paint事件。在事件中加入
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)
' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)
' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints)
End Sub
得到数据后,改point的数据。然后PictureBox1.Refresh()就行了