Draw Gradient on Form using VB.NET and GDI+

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 

How to use VB.NET and GDI+ to draw a gradient backcolor on the windows forms background.

        '
        'In the Form_Paint event. Put the following code:
        '
        'create a new recatangle
        '
        Dim rec As Rectangle = New Rectangle(0, 0, Me.Width, Me.Height)
        '
        'Create a new brush. Make is a Gradient style brush.
        '
        Dim myBrush As Brush = New Drawing.Drawing2D.LinearGradientBrush(rec, Color.Aqua, _
          Color.Yellow, Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal)
        '
        'draw the gradient onto the form.
        e.Graphics.FillRectangle(myBrush, rec)

One thought on “Draw Gradient on Form using VB.NET and GDI+

Leave a Reply