How I make a background transparent on my form? Is it possible in C#?
Solution 1:
A simple solution to get a transparent background in a winform is to overwrite the OnPaintBackground method like this:
protected override void OnPaintBackground(PaintEventArgs e)
{
//empty implementation
}
(Notice that the base.OnpaintBackground(e) is removed from the function)
Solution 2:
Put the following in the constructor of the form:
public Form1()
{
this.TransparencyKey = Color.Turquoise;
this.BackColor = Color.Turquoise;
}
This solution will not work if we use any animation in form. Otherwise it will working fine.
Solution 3:
Locate the constructor for your control class.The constructor appears in the control's code file. In Visual Basic, the constructor is the method named New. In C#, the constructor is the method with the same name as the control and with no return value. In the constructor, call the SetStyle method of your form.This will enable your control to support a transparent backcolor.SetStyle(ControlStyles.SupportsTransparentBackColor, true); After the line of code you added in the previous step, set your control's BackColor to Transparent.this.BackColor = Color.Transparent;Note that you can also create colors that are partially transparent using the FromArgb method. For more information on colors, see Using Managed Graphics Classes.
അരുണ് വാസു
No comments:
Post a Comment
Comment Here..