I\'ve already seen Transparent background on winforms?
it doesnt offer solution to my problem. I am using the same method to try to achieve transparency
The way I did it long time ago was to find an unused color for the form background and then set the transparency key to it:
this.BackColor = Color.Magenta;
this.TransparencyKey = Color.Magenta;
Other ways are:
[EDIT] As Mario states, normally the default transparent color for the key is Magenta.
public partial class TransprtScrcn : Form
{
public TransprtScrcn()
{
InitializeComponent();
this.BackColor = Color.Red;
this.TransparencyKey = Color.Red;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, e.ClipRectangle);
}
}
}
This is the best way to make the transparent background of winform.
right after this:
public partial class frmTransparentBackcolor : Form
{
public frmTransparentBackcolor()
{
InitializeComponent();
//set the backcolor and transparencykey on same color.
this.BackColor = Color.LimeGreen;
this.TransparencyKey = Color.LimeGreen;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.LimeGreen, e.ClipRectangle);
}
}
hope this will help.
You can use a picture for this work. The color of bound of picture is Red , Next use this code
this.TransparencyKey = Color.Red;