UserControl
-
Good day, I have a form, i've set the BackColor to Black and also the transparency to Black. then on the form a UserControl which has a gradient backcolor. Inside the UserControl i've put two basic controls(Label1 and Button1). I've set the BackColor of Label1 and Button1 to Transparent. What happened is that the Label1 and Button1 transparency goes through the form itself. See Link Below: http://www.geocities.com/fritzjeran/Sample.JPG What I really wanted is that when i set the BackColor of the Label1 and Button1 to transparent, I goes through ONLY up to the UserControl (i.e what should appear is the gradient color of usercontrol on the area that is overlapped by label1 and Button1). How should I fix this?:(( Here is the code of my Usercontrol:
public partial class BaseControl : UserControl { public BaseControl() { InitializeComponent(); SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.EnableNotifyMessage, true); } protected override void OnPaint(PaintEventArgs e) { if (this.BackgroundImage == null) { Rectangle rect = new Rectangle(0, 0, Width, Height); LinearGradientBrush b = new LinearGradientBrush(rect, Color.White, Color.Blue, 90); GraphicsPath path = GraphicsPathUtility.GetRoundRectPath(rect, 10); e.Graphics.FillPath(b, path); } base.OnPaint(e); } } #region Utility Classes public class GraphicsPathUtility { private GraphicsPathUtility() { } public static GraphicsPath GetRoundRectPath(RectangleF rect, float radius) { return GetRoundRectPath(rect.X, rect.Y, rect.Width, rect.Height, radius); } public static GraphicsPath GetRoundRectPath(float X, float Y, float width, float height, float radius) { GraphicsPath gp = new GraphicsPath(); gp.AddLine(X + radius, Y, X + width - (radius \* 2), Y); // gp.AddArc(X + width - (radius \* 2), Y, radius \* 2, radius \* 2, 270, 90);// gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius \* 2)); gp.AddArc(X + width - (radius \* 2), Y + height - (radius \* 2), radius \* 2, radius \* 2, 0, 90); gp.AddLine