Hi,
I've created an new user Button so i can control the way it looks by changing the background image on mouse/keyboard events. Is this an Ok way to change a buttons appearance.

Below is my user Control (inherited from System.Windows.Forms.Button)

It has properties to set the image of the button in it's different states
  1. Normal State
  2. Mouse Over State
  3. Pressed State


It also changes the image when the user presses the space bar

Thanks Ger

Here's a link to some examples (The text after bullet buttons are labels, with the same click event)
http://www.vbforums.com/

Here is a zip file with different button backgrounds
BackGroundImages.zip

VB Code:
  1. Public Class extButton
  2.     Inherits System.Windows.Forms.Button
  3.  
  4.     Private CustomButton As Boolean = False
  5.     Private bolMouseOver As Boolean = False
  6.     Private bolDrawBox As Boolean = False
  7.  
  8.     Private imgMouseOver As Image = Nothing
  9.     Private imgMouseDown As Image = Nothing
  10.     Private imgBackGround As Image = Nothing
  11.  
  12. #Region "**************** Design Properties ****************"
  13.     <System.ComponentModel.Category("Custom Design")> _
  14.         Public Property setCustomButton() As Boolean
  15.         Get
  16.             setCustomButton = CustomButton
  17.         End Get
  18.         Set(ByVal value As Boolean)
  19.             If CustomButton <> value Then
  20.                 CustomButton = value
  21.                 If CustomButton Then
  22.                     imgBackGround = Me.BackgroundImage
  23.                     Me.FlatStyle = Windows.Forms.FlatStyle.Flat
  24.                     Me.FlatAppearance.BorderSize = 0
  25.                     Try
  26.                         Me.FlatAppearance.CheckedBackColor = Me.Parent.BackColor
  27.                         Me.FlatAppearance.MouseDownBackColor = Me.Parent.BackColor
  28.                         Me.FlatAppearance.MouseOverBackColor = Me.Parent.BackColor
  29.                     Catch ex As Exception
  30.                         Me.FlatAppearance.CheckedBackColor = Color.Transparent
  31.                         Me.FlatAppearance.MouseDownBackColor = Color.Transparent
  32.                         Me.FlatAppearance.MouseOverBackColor = Color.Transparent
  33.                     End Try
  34.                 Else
  35.                     Me.FlatStyle = Windows.Forms.FlatStyle.Standard
  36.                 End If
  37.             End If
  38.         End Set
  39.     End Property
  40.  
  41.     <System.ComponentModel.Category("Custom Design")> _
  42.     Public Property DrawBoarder() As Boolean
  43.         Get
  44.             DrawBoarder = bolDrawBox
  45.         End Get
  46.         Set(ByVal value As Boolean)
  47.             bolDrawBox = value
  48.         End Set
  49.     End Property
  50.  
  51.     <System.ComponentModel.Category("Custom Design")> _
  52.     Public Property ImageNormal() As Image
  53.         Get
  54.             ImageNormal = imgBackGround
  55.         End Get
  56.         Set(ByVal value As Image)
  57.             imgBackGround = value
  58.             Me.BackgroundImage = value
  59.         End Set
  60.     End Property
  61.  
  62.     <System.ComponentModel.Category("Custom Design")> _
  63.     Public Property ImageMouseOver() As Image
  64.         Get
  65.             ImageMouseOver = imgMouseOver
  66.         End Get
  67.         Set(ByVal value As Image)
  68.             imgMouseOver = value
  69.         End Set
  70.     End Property
  71.  
  72.     <System.ComponentModel.Category("Custom Design")> _
  73.     Public Property ImageMouseDown() As Image
  74.         Get
  75.             ImageMouseDown = imgMouseDown
  76.         End Get
  77.         Set(ByVal value As Image)
  78.             imgMouseDown = value
  79.         End Set
  80.     End Property
  81. #End Region
  82.  
  83. #Region "**************** Mybase Handled events ****************"
  84.     Protected Overrides Sub onMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  85.         MyBase.OnMouseDown(e)
  86.         If CustomButton Then
  87.             Me.BackgroundImage = imgMouseDown
  88.         End If
  89.     End Sub
  90.  
  91.     Protected Overrides Sub onMouseEnter(ByVal e As System.EventArgs)
  92.         MyBase.OnMouseEnter(e)
  93.         If CustomButton Then
  94.             Me.BackgroundImage = imgMouseOver
  95.             bolMouseOver = True
  96.         End If
  97.     End Sub
  98.  
  99.     Protected Overrides Sub onMouseLeave(ByVal e As System.EventArgs)
  100.         MyBase.OnMouseLeave(e)
  101.         If CustomButton Then
  102.             Me.BackgroundImage = imgBackGround
  103.             bolMouseOver = False
  104.         End If
  105.     End Sub
  106.  
  107.     Protected Overrides Sub onMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  108.         MyBase.OnMouseUp(e)
  109.         If CustomButton Then
  110.             If bolMouseOver Then
  111.                 Me.BackgroundImage = imgMouseOver
  112.             Else
  113.                 Me.BackgroundImage = imgBackGround
  114.             End If
  115.         End If
  116.     End Sub
  117.  
  118.     Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
  119.         MyBase.OnKeyDown(e)
  120.  
  121.         If CustomButton Then
  122.             If e.KeyCode = Keys.Space Then
  123.                 Me.BackgroundImage = imgMouseDown
  124.             End If
  125.         End If
  126.     End Sub
  127.  
  128.     Protected Overrides Sub OnKeyUp(ByVal e As System.Windows.Forms.KeyEventArgs)
  129.         MyBase.OnKeyUp(e)
  130.         If CustomButton Then
  131.             If e.KeyCode = Keys.Space Then
  132.                 If bolMouseOver Then
  133.                     Me.BackgroundImage = imgMouseOver
  134.                 Else
  135.                     Me.BackgroundImage = imgBackGround
  136.                 End If
  137.             End If
  138.         End If
  139.     End Sub
  140.  
  141.     Protected Overrides Sub onPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  142.         MyBase.OnPaint(e)
  143.         If bolDrawBox Then
  144.             Dim pen As Pen = New Pen(Color.Black, 1)
  145.             Dim rect As New Rectangle(0, 0, Me.Width - 1, Me.Height - 1)
  146.             Dim pp As Drawing2D.GraphicsPath = RoundRectPath(rect, 2)
  147.             e.Graphics.DrawPath(pen, pp)
  148.  
  149.             pen.Dispose()
  150.             pp.Dispose()
  151.         End If
  152.     End Sub
  153.  
  154. #End Region
  155.  
  156.     Public Shared Function RoundRectPath(ByVal rect As Rectangle, ByVal cornerRadius As Integer) As Drawing2D.GraphicsPath
  157.         Dim cornerDiameter As Integer = cornerRadius * 2
  158.         Dim pp As New Drawing2D.GraphicsPath()
  159.         pp.AddLine(rect.Left + cornerRadius, rect.Top, rect.Right - cornerRadius, rect.Top)   'top
  160.         pp.AddArc(New Rectangle(rect.Right - cornerDiameter, rect.Top, cornerDiameter, cornerDiameter), 270, 90)   'topRight
  161.         pp.AddLine(rect.Right, rect.Top + cornerRadius, rect.Right, rect.Bottom - cornerRadius) 'right
  162.         pp.AddArc(New Rectangle(rect.Right - cornerDiameter, rect.Bottom - cornerDiameter, cornerDiameter, cornerDiameter), 0, 90)   'bottomRight
  163.         pp.AddLine(rect.Right - cornerRadius, rect.Bottom, rect.Left + cornerRadius, rect.Bottom)   'bottom
  164.         pp.AddArc(New Rectangle(rect.Left, rect.Bottom - cornerDiameter, cornerDiameter, cornerDiameter), 90, 90)   'bottomLeft
  165.         pp.AddLine(rect.Left, rect.Bottom - cornerRadius, rect.Left, rect.Top + cornerRadius) 'left
  166.         pp.AddArc(New Rectangle(rect.Left, rect.Top, cornerDiameter, cornerDiameter), 180, 90)   'topLeft
  167.         pp.CloseFigure()
  168.         Return pp
  169.     End Function
  170. End Class