[英]I am trying to draw a circle in 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
I am trying to draw a circle in VB.Net, .Net version 4. Nothing shows up in the paintbox. 我试图在VB.Net,.Net版本4中绘制一个圆圈。在paintbox中没有显示任何内容。
Try to use: 尝试使用:
e.Graphics.DrawEllipse(Pens.AliceBlue,e.ClipRectangle);
It worked for me. 它对我有用。
You can also try to use: 您也可以尝试使用:
e.Graphics.DrawEllipse(
Pens.AliceBlue,
0, 0,
pictureBox1.Width-1, pictureBox1.Height-1);
Or 要么
Rectangle rect = e.ClipRectangle;
rect.Inflate(-1, -1);
e.Graphics.DrawEllipse(Pens.AliceBlue, rect);
Your code works for me, except that Color.AliceBlue
is almost identical to KnownColor.Control
. 您的代码适用于我,但
Color.AliceBlue
几乎与KnownColor.Control
相同。
rr gg bb
Color.AliceBlue.ToArgb = F0 F8 FF
KnownColor.Control.ToArgb = F0 F0 F0
Difference = 00 08 0F
Try Pens.Navy
: 试试
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
http://msdn.microsoft.com/en-us/library/a3fd63x2(v=vs.80).aspx#Y1128 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.