*******protected overrides sub OnPaint(ByVal e As****** ******System.Windows.Forms.PaintEventArgs)******** Dim g As Graphics = e.Graphics Dim pn As Pen = New Pen(Color.Green, 10) g.DrawLine(pn, 100, 10, 30, 10) g.DrawEllipse(New Pen(Color.Red, 20), 20, 40, 20, 20) End Sub _____________________________________________________________________ Imports System Imports System.Drawing Imports System.Drawing.Drawing2D *******Public Class Form1 *******Inherits System.Windows.Forms.Form ******** Dim imgType As Integer = 0 #Region " Windows Form Designer generated code " ‘ code generated by designer here #End Region ******Protected Overrides Sub OnPaint(ByVal e As***** ******System.Windows.Forms.PaintEventArgs)********* Dim g As Graphics = e.Graphics If imgType = 1 Then Dim pn As Pen = New Pen(Color.Blue, 100) Dim rect As Rectangle = New Rectangle(50, 50, 200, 100) g.DrawEllipse(pn, rect) End If If imgType = 2 Then Dim rect As Rectangle = New Rectangle(50, 30, 100, 100) Dim lBrush As LinearGradientBrush = New LinearGradientBrush(rect, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal) g.FillRectangle(lBrush, rect) End If If imgType = 3 Then Dim pn As Pen = New Pen(Color.Blue) Dim rect As Rectangle = New Rectangle(50, 50, 200, 100) g.DrawArc(pn, rect, 12, 84) End If If imgType = 4 Then g.DrawString("Welcome to the Graphics World",******** Me.Font*******, New SolidBrush(Color.Red), 20, 20) End If If imgType = 5 Then Dim pn As Pen = New Pen(Color.Blue) Dim rect As Rectangle = New Rectangle(50, 50, 200, 100) Dim pt1 As Point = New Point(30, 30) Dim pt2 As Point = New Point(110, 100) g.DrawLine(pn, pt1, pt2) End If If imgType = 6 Then Dim rect As Rectangle = New Rectangle(50, 30, 200, 200) Dim lBrush As LinearGradientBrush = New LinearGradientBrush(rect, Color.Blue, Color.Green, LinearGradientMode.Vertical) g.FillRectangle(lBrush, rect) End If If imgType = 0 Then Dim pn As Pen = New Pen(Color.Green, 10) g.DrawLine(pn, 100, 10, 30, 10) g.DrawEllipse(New Pen(Color.Red, 20), 20, 40, 20, 20) g.DrawBezier(New Pen(Color.Blue, 5), New Point(50, 60), New Point(150, 10), New Point(200, 230), New Point(100, 100)) Dim point1 As PointF = New PointF(50F, 250F) Dim point2 As PointF = New PointF(100F, 25F) Dim point3 As PointF = New PointF(150F, 5F) Dim point4 As PointF = New PointF(250F, 50F) Dim point5 As PointF = New PointF(300F, 100F) Dim curvePoints As PointF() = {point1, point2, point3, point4, point5} g.DrawPolygon(New Pen(Color.Chocolate, 10), curvePoints) End If End Sub ' ellipse Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click imgType = 1 *********Invalidate() ******* End Sub 'rectangle Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click imgType = 2 *******Invalidate()******* End Sub ' arc Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click imgType = 3 ********Invalidate() **** End Sub 'text Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click imgType = 4 *******Invalidate()****** End Sub ‘line Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ine.Click imgType = 5 *****Invalidate() ******** End Sub 'gradient Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem7.Click imgType = 6 *******Invalidate()******* End Sub End Class