[IMG]http://www.[censored].net/uploads/1d26029562.gif[/IMG]
ow to do that WITHOUT using any images?
We just need 1 Button (of course), 2 events for calling our function, and our same Function from before (which is here slightly modified).
Here is the Function, I call it this time PaintGradient.
Now we will use 2 events from our Button, MouseEnter and MouseLeave
That's it, you are done. :lol:
ow to do that WITHOUT using any images?
We just need 1 Button (of course), 2 events for calling our function, and our same Function from before (which is here slightly modified).
Here is the Function, I call it this time PaintGradient.
Code
Public Sub PaintGradient(ByVal aControl As Control, ByVal Color1 As Color, ByVal Color2 As Color, _
Optional ByVal mode As System.Drawing.Drawing2D.LinearGradientMode = Drawing2D.LinearGradientMode.Vertical)
Dim bmp As New Bitmap(aControl.Width, aControl.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim Rect1 As New RectangleF(0, 0, aControl.Width, aControl.Height)
Dim lineGBrush As New System.Drawing.Drawing2D.LinearGradientBrush(Rect1, Color1, Color2, mode)
g.FillRectangle(lineGBrush, Rect1)
aControl.BackgroundImage = bmp
g.Dispose()
End SubNow we will use 2 events from our Button, MouseEnter and MouseLeave
Code
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
PaintGradient(Button1, Color.LightGoldenrodYellow, Color.YellowGreen)
End Sub
Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
Button1.BackgroundImage = Nothing
End SubThat's it, you are done. :lol:

