Hi,
To change the controls background color to transparent you need not set
ControlStyle SupportsTransparentBackColor to true . Moreover,
inside the OnPaint method, e.Graphics.Clear(Color.BackColor); is also not
required
you can instead write
base.OnPaint(pevent); in your OnPaint method and it will work fine.
I have tried the following code and it works fine for me
public class rb : RadioButton
{
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
}
}
private void Form1_Load(object sender, EventArgs e)
{
rb r1 = new rb();
r1.BackColor = Color.Transparent;
this.Controls.Add(r1);
}
> Hi All,
>
[quoted text clipped - 12 lines]
>
> Thanks!
joshuaphillips@comcast.net - 16 Aug 2005 19:37 GMT
Thanks Swashi,
Unfortunately this doesn't work for me. The whole reason I created a
custom radio button was to be able to override its OnPaint method, and
paint and image instead of the standard circle. I wonder what the code
MS uses that paints transparency. I'll keep looking...
Josh
> Hi,
> To change the controls background color to transparent you need not set
[quoted text clipped - 41 lines]
> >
> > Thanks!
joshuaphillips@comcast.net - 16 Aug 2005 19:59 GMT
I actually figured it out. In my OnPaint method, I deleted the
Graphics.Clear(Color.BackColor) and just called
base.OnPaintBackground(e). That seemed to do the trick!