VB.NET tutorial-VB.NET draw ellipses


VB.NET draw ellipses

To draw an ellipse shape on the control, you can use the drawEllipse() method. The drawEllipse() method requires two parameters. The first parameter is a pen object and the  second is the rectangle object.

Example: drawing three ellipses on the form


Public Class Form1
   
    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       
       'Create pen objects
        Dim p0 As New Pen(Color.Green, 10)
        Dim p1 As New Pen(Color.Yellow, 10)
        Dim p2 As New Pen(Color.Red, 10)
 
        'Create rectangle objects
        Dim rt0 As New Rectangle(100, 150, 80, 100)
        Dim rt1 As New Rectangle(130, 120, 120, 120)
        Dim rt2 As New Rectangle(160, 100, 150, 150)
 
        'Draw ellipse
       
        e.Graphics.DrawEllipse(p0, rt0)
        e.Graphics.DrawEllipse(p1, rt1)
     e.Graphics.DrawEllipse(p2, rt2)
 
    End Sub
 
End Class

VB.NET code example to draw ellipses


 



Comments





This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.