VB.NET tutorial-VB.NET draw pie chart


VB.NET draw pies

To draw a pie shape on the form, you can use the DrawPie(Pen, Rectangle_Obj,Start_Angle, Stop_Angle) method.

Example: Draw three pies on the current 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 pies
 
        e.Graphics.DrawPie(p0, rt0, 0, -180)
        e.Graphics.DrawPie(p1, rt1, 0, -180)
        e.Graphics.DrawPie(p2, rt2, 0, -180)
    End Sub
 
End Class

 

VB example code to draw pies  




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.