
正文
vb.net画标尺 vb画图代码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
VB.net中如何画图?
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
相关问答
Q1: 怎样在vb.net的picturebox里画出坐标啊?
自己用GDI+画的 无论什么什么尺寸的picturebox都行
不过别太小了o(∩_∩)o
代码放在哪里自己决定啊
最好是放在 picturebox的resize时间里
每次picturebox大小改变都重画一次坐标
Dim b As New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(Color.White)
Dim p As New Pen(Color.Black)
p.EndCap = Drawing2D.LineCap.ArrowAnchor
g.DrawLine(p, 30, PictureBox1.Height - 30, 30, 30)
g.DrawLine(p, 30, PictureBox1.Height - 30, PictureBox1.Width - 30, PictureBox1.Height - 30)
Dim i As Integer
Dim bs As New SolidBrush(Color.Green)
Dim po As New Point
po.X = 0
po.Y = PictureBox1.Height - 35
For i = 700 To 1000 Step 50
g.DrawString(i, Me.Font, bs, po.X, po.Y)
g.DrawLine(p, po.X + 28, po.Y + 5, po.X + 30, po.Y + 5)
po.Y -= (PictureBox1.Height - 100) / 6
Next
po.X = 30
po.Y = PictureBox1.Height - 30
For i = 0 To 40 Step 5
g.DrawString(i, Me.Font, bs, po.X, po.Y + 5)
g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)
po.X += (PictureBox1.Width - 100) / 8
Next
PictureBox1.Image = b
Q2: vb.net 制作行标尺
左边放一个专门放行数的listbox,根据右边的行数自动生成行号
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Dim arr() = RichTextBox1.Text.Split(vbLf)
Dim str As String
str = ""
For i = 1 To arr.Length
str = str i vbCrLf
Next
RichTextBox2.Text = str
End Sub
接下来是两个listbox的同步滚动,可以参考这篇文章:
vb.net画标尺的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb画图代码、vb.net画标尺的信息别忘了在本站进行查找喔。





