vb.net画图笔刷 vb画画

VB.net中如何画图?分类:电脑/网络程序设计其他编程语言
问题描述:
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
vb.net 绘图,重绘知识继承(Inherits)控件就可以重写它的属性和方法,图标可以在paint中重绘 , 用gdi,工具主要在drawing和drawing2d中 。
combobox弹出的框增加图标吗?个人看法可能需要得到那个句柄,才可以重绘,但那个好像是一体的 , 不知道能不能弄到句柄 。
textbox可以自定义高度 。只是以行高度为单位,改变字体大小即可 , 没必要重写吧 。
我也自学,感觉基础容易学,进阶资料少 。循序渐进也没序可循,基本是在摸索 。
都是想到什么问题,就立下一个目标,然后攻破他,结果可能是尝试几天后,发现目标超出能力范围 。
晦涩是相对的 , 实践出真知 , 多动手,基础就好了 。
vb.net GDI绘图刷新问题绘图代码写在Paint事件中,如
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Red, 100, 100, 200, 100)
End Sub
'方法二:在 PictureBox1上显示图像----图画在Bitmap
【vb.net画图笔刷 vb画画】PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
VB.net一个很简单的UI问题花了二十分钟给你写了代码,已测试 。建议学习并使用System.Drawing绘制 。
主要是掌握Graphics.FillRectangle和DrawString的使用 。
Imports System.Drawing
Public Class 进度条UI
Public 上面笔刷 As SolidBrush = New SolidBrush(Color.FromArgb(192, 175, 238, 238))
Public 下面笔刷 As SolidBrush = New SolidBrush(Color.FromArgb(192, 30, 144, 255))
Public 文字笔 As SolidBrush = New SolidBrush(Color.FromArgb(255, 255, 255, 255))
Public 字体 As Font = New Font("微软雅黑", 14.0)
Public 文字格式 As StringFormat = New StringFormat() With
{.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
''' summary
''' 绘制指定进度的图像 。
''' 当进度变化时调用一次本方法,建议将创建的Graphics对象保存到变量而不要重复创建 。。
''' /summary
''' param name="控件"绘制到此控件的工作区/param
''' param name="g"绘制到控件的Graphics对象,例如 Button1.CreateGraphics()/param
''' param name="进度"进度百分比实数,57% = 0.57/param
Public Sub 绘制(ByRef 控件 As Control, ByRef g As Graphics, ByVal 进度 As Double)
Dim 矩形 = 控件.ClientRectangle '获取控件的工作区矩形
Dim 下面高度 = CInt(矩形.Height * 进度) '获取下面颜色块的高度

推荐阅读