VB.net與VB不同。
成都創(chuàng)新互聯(lián)公司專注于網(wǎng)站設計、成都網(wǎng)站建設、網(wǎng)頁設計、網(wǎng)站制作、網(wǎng)站開發(fā)。公司秉持“客戶至上,用心服務”的宗旨,從客戶的利益和觀點出發(fā),讓客戶在網(wǎng)絡營銷中找到自己的駐足之地。尊重和關懷每一位客戶,用嚴謹?shù)膽B(tài)度對待客戶,用專業(yè)的服務創(chuàng)造價值,成為客戶值得信賴的朋友,為客戶解除后顧之憂。
VB.net已經(jīng)有專門繪圖的類。
可以定義筆刷然后用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的 ?編譯 ?上面都有詳細的參數(shù)說明
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. 創(chuàng)建一個Graphics對象實例。
繪制圖形必須創(chuàng)建Graphics對象。如果是在窗體上繪圖,要使用下列代碼創(chuàng)建Graphics對象;
Dim MyGraphics As Graphics = Me.CreateGraphics
如果是在PictrueBox里繪圖,要使用下列代碼創(chuàng)建Graphics對象;
Dim MyGraphics As Graphics = PictureBox1.CreateGraphics
2. 定義一個Brush對象,用來填充圖形(如果你需要填充的話)。
如果填充封閉曲線或者多邊形,必須創(chuàng)建Brush對象(或者Brush類的繼承類對象),用來確定填充的顏色。例如下面的代碼,創(chuàng)建了一個填充紅色的畫刷對象。在最后的括號里,用Color結構指定的枚舉值,確定畫刷的顏色。限于篇幅有關Color結構這里不展開,可能在后續(xù)博文里介紹。
Dim RedBrush As New SolidBrush(Color.Red)
你可以通過用VB.net控制excel,讓excel生成曲線圖,然后利用excelVBA將圖輸出,最后導入到VB.net就可以了。
拖一個PictureBox1控件
創(chuàng)建一個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
得到數(shù)據(jù)后,改point的數(shù)據(jù)。然后PictureBox1.Refresh()就行了