Murray Brown
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(m yLGBrush, 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(m yLGBrush, 20, 150, 200, 100)
' Rejustify the brush to start at the top edge of the rectangle.
myLGBrush.TranslateTransfo rm(-20.0F, 0.0F)
' Draw a third rectangle to the screen using the translated brush.
e.Graphics.FillRectangle(m yLGBrush, 20, 300, 200, 100)
End Sub
Thanks
Public Sub TranslateTransformExample(
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New LinearGradientBrush(myRect
Color.Red, 0.0F, True)
' Draw a rectangle to the screen using the LinearGradientBrush.
e.Graphics.FillRectangle(m
' Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(
' Scale the gradient for the height of the rectangle.
myLGBrush.ScaleTransform(0
' Draw to the screen, the rotated and scaled gradient.
e.Graphics.FillRectangle(m
' Rejustify the brush to start at the top edge of the rectangle.
myLGBrush.TranslateTransfo
' Draw a third rectangle to the screen using the translated brush.
e.Graphics.FillRectangle(m
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the button does not support it natively. it is not very complex, juxt copy and paste
ASKER
Thanks very much
ASKER
Great answer. Thank you
ASKER