mercredi 1 avril 2015

How do I make component's background transparent on form?

this is my code for the component. I got the solution to make the backcolor transparent from the Microsoft website, and from stack overflow but it doesn't work:



public RedCircle()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
InitializeComponent();
this.Paint += new PaintEventHandler(RedCircle_Paint);

}

private void RedCircle_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.FillEllipse(Brushes.Red, new Rectangle(5, 5, 25, 25));
}


End result on form:


enter image description here


Aucun commentaire:

Enregistrer un commentaire