Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Use Linear Gradient brush on a button control

Hi. How would I apply the same sort of formatting as used in the procedure below on a button, with the gradient getting lighter from top to bottom.

Thanks

Public Sub TranslateTransformExample(ByVal e As PaintEventArgs)

    ' Create a LinearGradientBrush.
    Dim myRect As New Rectangle(20, 20, 200, 100)
    Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
    Color.Red, 0.0F, True)

    ' Draw a rectangle to the screen using the LinearGradientBrush.
    e.Graphics.FillRectangle(myLGBrush, myRect)

    ' Rotate the LinearGradientBrush.
    myLGBrush.RotateTransform(90.0F)

    ' Scale the gradient for the height of the rectangle.
    myLGBrush.ScaleTransform(0.5F, 1.0F)

    ' Draw to the screen, the rotated and scaled gradient.
    e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100)

    ' Rejustify the brush to start at the top edge of the rectangle.
    myLGBrush.TranslateTransform(-20.0F, 0.0F)

    ' Draw a third rectangle to the screen using the translated brush.
    e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100)
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Hi. Thanks. That is complex and not easy to ny chance of something a little simpler. Thanks
the button does not support it natively. it is not very complex, juxt copy and paste
Thanks very much
Great answer. Thank you