Privacy Policy


Best viewed with:
Mick Dohertys' .net Tips and Tricks - Tips / Button
Get a free giffgaff Sim
Windows XP themed buttons don't show an Image.

Unfortunately when you want to apply Visual Styles to a button you must set it's Flatsyle property to System. Doing this causes the button not to display the image or ForeColor associated with it. The following class overcomes this by applying Visual Styles when the button's Flatsyle is set to Standard.
A State property has also been added to the class so that if you wish to add some painting in the Paint event you will know what the current state of the button is.

  • VB Code
  • C# Code

There's a bit more to it than just overriding OnPaint.


Windows XP themed buttons don't show an Image (an alternative method).

This class is much simpler than the one above, but it only works on XP Styled System buttons. If XP Visual Styles are not in use then the button will still not show an image. The advantage to this method is that there is no special handling necessary in order to know which state to draw the button in as we still allow the System to draw the button, unlike in the class above in which we draw the Visual Styled button ourselves.

  • VB Code
  • C# Code


Creating Custom Buttons by Implementing IButtonControl.

No need to Inherit from Button if you want a button with a completely custom appearance. The following class defines a Custom Button which can be set as a forms AcceptButton or CancelButton, but which is inherited from Control rather than Button. It also includes a custom TypeEditor to allow selection of corners to be rounded.

  • VB Code
  • C# Code

note that this example needs a reference to System.Design.dll since it uses a custom TypeEditor.