VB.net中如何画图?

VB.net中如何画图?,第1张

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述:

VB6中的form1.circle (100,200),rgb(0,255,0)的语句如何在VB中使用啊?

急用啊!!!!!!!!

解析:

VB与VB不同。

VB已经有专门绘图的类。

可以定义笔刷然后用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

在窗口添加一个Command1按钮,输入如下代码

Private

Sub

Command1_Click()

On

Error

Resume

Next

CommonDialog1.CancelError

=

True

CommonDialog1.DialogTitle

=

"颜色"

CommonDialog1.ShowColor

If

Err

<>

32755

Then

Picture1.ForeColor

=

CommonDialog1.Color

End

If

End

Sub

提供一个绘制任意曲线的简单代码。其他功能类似,希望能举一反三。

在窗体中添加一个Picture box,然后输入命令如下:

Dim oldx As Single

Dim oldy As Single

 Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = 1 Then       '当鼠标左建按下时发生

        Picture1.Line (oldx, oldy)-(X, Y)

        oldx = X

        oldy = Y

    End If

End Sub

  

Private Sub Picture1_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    oldx = X

    oldy = Y

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12050289.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-20
下一篇2023-05-20

发表评论

登录后才能评论

评论列表(0条)

    保存