簡體   English   中英

我想在VB.Net中畫一個圓圈

[英]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

我試圖在VB.Net,.Net版本4中繪制一個圓圈。在paintbox中沒有顯示任何內容。

嘗試使用:

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

您的代碼適用於我,但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 

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM