vb.net清除绘图 vb清除命令
vb.net中用Graphics.DrawString画一字符串后,怎么再将它擦掉??请各位高手帮帮忙!!!
把字符串设置成和底颜色一样,然后再写一次就行了
成都创新互联主营麦积网站建设的网络公司,主营网站建设方案,App定制开发,麦积h5微信小程序开发搭建,麦积网站营销推广欢迎麦积等地区企业咨询
当然这个是取巧的办法
vb.net绘图问题
代码:
Public Class Form1
'*********************************************************************
'作者:章鱼哥,QQ:3107073263 群:309816713
'如有疑问或好的建议请联系我,大家一起进步
'*********************************************************************
'绘制圆角矩形函数
Private Function GetRoundedRectPath(ByVal rect As Rectangle, ByVal radius As Integer) As System.Drawing.Drawing2D.GraphicsPath
rect.Offset(-1, -1)
Dim RoundRect As New Rectangle(rect.Location, New Size(radius - 1, radius - 1))
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect, 180, 90) '左上角
RoundRect.X = rect.Right - radius '右上角
path.AddArc(RoundRect, 270, 90)
RoundRect.Y = rect.Bottom - radius '右下角
path.AddArc(RoundRect, 0, 90)
RoundRect.X = rect.Left '左下角
path.AddArc(RoundRect, 90, 90)
path.CloseFigure()
Return path
End Function
'绘制矩形
Private Sub DrawingRect()
Dim g As Graphics = Me.CreateGraphics
Dim Pen As New Pen(Brushes.DarkRed, 2)
Dim Hei As Integer = Me.Height
Dim Wid As Integer = Me.Width
'矩形的位置和长宽随着窗体的变化而改变
Dim Rec As New Rectangle(Int(Wid / 5), Int(Hei / 5), Int(Wid / 2), Int(Hei / 2))
' g.DrawRectangle(Pen, Rec)
'清楚现有的矩形
g.Clear(Me.BackColor)
g.DrawPath(Pen, GetRoundedRectPath(Rec, 30))
End Sub
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
DrawingRect()
End Sub
Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
Me.Invalidate() '此函数可引发Paint事件
End Sub
End Class
效果截图:
原窗口:
缩小后:
vb.net 中如何用代码移除窗体或按钮的背景图?
开一个 button 控件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.BackgroundImage = Nothing
End Sub
释放掉背景就好了
按钮也一样
请问vb.net中如何实现窗体的清空
要在VB.NET中清屏已经不再是象是在VB6中那么简单使用一条Cls就能搞定的,因为现在的VB.NET已经是完全面向对象的语言了,方法就不能和以前那样了,下面给出清空窗体的源代码,通过单击按钮清空,如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics
g = Me.CreateGraphics
g.Clear(Me.BackColor)
g.Dispose()
'释放对象g所占用的资源
End Sub
OK,程序已经成功实现你要的功能,运行环境VS.NET2003+Windows 2003 Server
欢迎你加入群:30538950进行交流!
网站题目:vb.net清除绘图 vb清除命令
网站路径:http://myzitong.com/article/dosjcpe.html