' Override the OnPaint event for this form.
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
' Declare a variable of type Graphics named formGraphics.
' Assign the address (reference) of this forms Graphics object
' to the formGraphics variable.
Dim formGraphics As Graphics = e.Graphics
' Declare a variable of type LinearGradientBrush named gradientBrush.
' Use a LinearGradientBrush constructor to create a new LinearGradientBrush object.
' Assign the address (reference) of the new object
' to the gradientBrush variable.
Dim gradientBrush As New LinearGradientBrush(New Point(0, 0), New Point(Width, 0), Color.White, Color.DarkMagenta)
' Here are two more examples that create different gradients.
' Comment the Dim statement immediately above and uncomment one of these
' Dim statements to see how varying the two colors changes the gradient result.
' Dim gradientBrush As New LinearGradientBrush(New Point(0, 0), New Point(Width, 0), Color.Chartreuse, Color.SteelBlue)
' Dim gradientBrush As New LinearGradientBrush(New Point(0, 0), New Point(Width, 0), Color.White, Color.SteelBlue)
formGraphics.FillRectangle(gradientBrush, ClientRectangle)
End Sub