[英]Draw circle over my form with VB.Net
我怎么能在我的表格上畫圓圈?
我試過的:
Dim bmp As New Bitmap(Me.Width, Me.Height)
cWidth = 3
Me.BackgroundImage = Circle (Me.Width, Me.Height,bmp,cWidth)
重寫OnPaint事件處理程序並從那里執行,f.ex:
Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim myPen As New Pen(Color.Red, 3) 'to set width of pen
e.Graphics.DrawEllipse(myPen, 0, 0, _
Me.ClientSize.Width - 1, Me.ClientSize.Height - 1)
myPen.Dispose()
End Sub
好的,這是一個圓圈 ;-)
Public Class Form1
Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim p As Pen
Dim d As Integer
Dim x As Integer
d = Math.Min(Me.ClientRectangle.Width, Me.ClientRectangle.Height)
x = Me.ClientRectangle.Width / 2 - d / 2
p = New Pen(Brushes.Navy, 7)
e.Graphics.DrawEllipse(p, New Rectangle(x, 0, d, d))
End Sub
Private Sub Form1_Resize(sender As System.Object, e As System.EventArgs) Handles MyBase.Resize
Me.Invalidate()
End Sub
End Class
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.