我怎么能在我的表格上画圆圈?
我的尝试:
Dim bmp As New Bitmap(Me.Width, Me.Height)
cWidth = 3
Me.BackgroundImage = Circle (Me.Width, Me.Height,bmp,cWidth)
答案 0 :(得分:1)
重写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
答案 1 :(得分:1)
好的,这里有圈; - )
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