2011-11-03 145 views
4
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中绘制一个圆圈。 没有在油漆盒中显示出来。我想在VB.Net中画一个圆圈

+1

你肯定Paint事件实际上是射击? –

回答

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); 
+0

@ user366866:我的回答是否帮助您解决了您的问题? :) – Marco

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) 
+0

那么,这与原始代码有什么不同?有什么区别,使其工作(与原始代码相比)?它的示例MSDN代码 – Heinzi

+0

,如果代码不起作用它总是很好看MSDN示例。与OPs代码略有不同。 OP只提供单一功能的代码,如果这些答案仍然不起作用,则表明这是一个不同的问题,我相信我们会深入其中。 – JonAlb

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