VB.NET tutorial-fill shapes with solid brush

Fill shapes with solid brush

Closed shapes that are drawn on the control can be filled with a color or a mix of colors. You can fill a rectangle shape with a color by using FillRectangle() method. Filling an ellipse can be done with FillEllipse() method and FillPie() method to fill the pie shape.

Example: Filling the rectangle, ellipse, and pie shapes with different colors.

Public Class Form1
    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       'Create brush objects
        Dim br0 As New SolidBrush(Color.Cyan)
        Dim br1 As New SolidBrush(Color.Coral)
        Dim br2 As New SolidBrush(Color.CadetBlue)
        'Create rectangle objects
        Dim rt0 As New Rectangle(100, 150, 80, 100)
        Dim rt1 As New Rectangle(190, 120, 120, 120)
        Dim rt2 As New Rectangle(320, 100, 150, 150)
        'Fill shapes
        e.Graphics.FillRectangle(br0, rt0)
        e.Graphics.FillPie(br1, rt1, 0, -180)
        e.Graphics.FillEllipse(br2, rt2)   
   End Sub
End Class

VB.NET to fill shapes with solid brush


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.