Custom control transparency in WinForms

Recently, I created a custom control that collapses its self. This control was to be round in shape so the background had to be transparent. But when I set the BackColor = Color.Transparent I received this message; “This control does not support transparent background colors.” I felt like Lil’ Jon “WHAT!” After some research I found the solution: SetStyle. The SetStyle method enables or disables certain ControlStyles for a control. So if your custom control needs to use transparency or an alpha color less than 255 use this:

SetStyle(ControlStyles.SupportsTransparentBackColor, True)

Now Playing: Alicia Keys – Karma