Draw shape according to combobox selection

Following example uses a combobox control to draw a shape. In this example we bind names of different type of shape such as circle,square, pie etc.

when user select any shape from combobox then example draw that shape on specified location on the windows form.

Code for binding names of the different shapes.

Private Sub Form1_Load(ByVal sender As System.Object, _
                           ByVal e As System.EventArgs) Handles MyBase.Load
        cboxImage.Items.AddRange(New Object() {"Circle", "Square", "Ellipse", "Pie", "Filled Circle", "Filled Square", "Filled Ellipse", "Filled Pie"})
End Sub

Draw selected shape:

Private Sub cboxImage_Selectedindexchanged(ByVal Sender As System.Object, _
                                ByVal E As System.EventArgs) Handles cboxImage.SelectedIndexChanged
        Dim objGraphics As Graphics = MyBase.CreateGraphics()
        Dim objPen As New Pen(Color.Blue)
        Dim objBrush As New SolidBrush(Color.Blue)
        Dim X As Integer = 30
        Dim Y As Integer = 30
        Dim Width As Integer = 100
        Dim Height As Integer = 100
        Select Case cboxImage.SelectedIndex
            Case 0
                objGraphics.DrawEllipse(objPen, X, Y, Width, Height)
            Case 1
                objGraphics.DrawRectangle(objPen, X, Y, Width, Height)
            Case 2
                objGraphics.DrawEllipse(objPen, X, Y, Width, 75)
            Case 3
                objGraphics.DrawPie(objPen, X, Y, Width, Height, 0, 45)
            Case 4
                objGraphics.FillEllipse(objBrush, X, Y, Width, Height)
            Case 5
                objGraphics.FillRectangle(objBrush, X, Y, Width, Height)
            Case 6
                objGraphics.FillEllipse(objBrush, 50, 85, 150, 115)
            Case 7
                objGraphics.FillPie(objBrush, 50, 50, 150, 150, 0, 45)
        End Select
End Sub