Drawing a transparent button

WinForms (and underlying User32) does not support transparency at all. WinForms however can simulate transparency by using control style you provide – SupportsTransparentBackColor, but in this case all that “transparent” control does, it to allow drawing parent its background.

ButtonBase uses some windows styles that prevent working this mechanism. I see two solutions: one is to derive your control from Control (instead of ButtonBase), and second is to use Parent’s DrawToBitmap to get background under your button, and then draw this image in OnPaint.

Leave a Comment