469,931 Members | 2,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,931 developers. It's quick & easy.

Custom Control With Transparent Background

How can I give my custom System.Windows.Forms.Control a transparent
background? In the small application below I expect to see two partially
overlapping circles, a blue one and a red one, but only the blue circle

What more can I do to make the background truly transparent?

using System.Drawing;
using System.Windows.Forms;

//class ColorCircleControl
class ColorCircleControl:Control

//data member brush
Brush brush;

//data members x,y
int x;
int y;

//data member width
int width;

public ColorCircleControl(Brush a,int b,int c,int d)
SetStyle(ControlStyles.SupportsTransparentBackColo r,true);

void OnPaint(object a,PaintEventArgs b)

//class MyForm
class MyForm:Form

public MyForm()
Controls.Add(new ColorCircleControl(Brushes.Blue,55,89,89));
Controls.Add(new ColorCircleControl(Brushes.Red,144,89,55));
ClientSize=new System.Drawing.Size(597,370);

static void Main()
System.Windows.Forms.Application.Run(new MyForm());
Sep 13 '06 #1
0 1294

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Steve | last post: by
1 post views Thread by Efkas | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.