我想在VB.Net中画一个圆圈

时间:2011-11-03 08:07:04

标签: .net vb.net

Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
    e.Graphics.DrawEllipse(Pens.AliceBlue, New Rectangle(New Point(0, 0), New Size(PictureBox1.Width, PictureBox1.Height)))


End Sub

我想在VB.Net,.Net版本4中绘制一个圆圈。 没有任何东西出现在绘图箱中。

3 个答案:

答案 0 :(得分:5)

尝试使用:

e.Graphics.DrawEllipse(Pens.AliceBlue,e.ClipRectangle);

对我有用。
您也可以尝试使用:

e.Graphics.DrawEllipse(
    Pens.AliceBlue,
    0, 0,
    pictureBox1.Width-1, pictureBox1.Height-1);

或者

Rectangle rect = e.ClipRectangle;
rect.Inflate(-1, -1);
e.Graphics.DrawEllipse(Pens.AliceBlue, rect);

答案 1 :(得分:1)

您的代码适用于我,但Color.AliceBlue几乎与KnownColor.Control完全相同。

                            rr gg bb
Color.AliceBlue.ToArgb    = F0 F8 FF
KnownColor.Control.ToArgb = F0 F0 F0
Difference                = 00 08 0F

尝试Pens.Navy

Private Sub PictureBox1_Paint(sender As System.Object, e As PaintEventArgs) Handles PictureBox1.Paint
    e.Graphics.DrawEllipse(Pens.Navy, New Rectangle(New Point(0, 0), PictureBox1.Size)) 
End Sub 

答案 2 :(得分:0)

http://msdn.microsoft.com/en-us/library/a3fd63x2(v=vs.80).aspx#Y1128

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create rectangle for ellipse.
Dim rect As New Rectangle(0, 0, 200, 200)

' Draw ellipse to screen.
e.Graphics.DrawEllipse(blackPen, rect)