0

我怎样才能在我的表格上画圈?

我试过的:

Dim bmp As New Bitmap(Me.Width, Me.Height)
cWidth = 3
Me.BackgroundImage = Circle (Me.Width, Me.Height,bmp,cWidth)
4

2 回答 2

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
于 2012-11-02T00:00:54.157 回答
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
于 2012-11-02T00:08:53.087 回答